Fix for broken logic of the ClassLock (showed up on Ubuntu Hardy)

this was nice copy-n-paster error, of course the implementation
namespace was never intended to be anonymous.
This commit is contained in:
Fischlurch 2009-01-21 12:19:02 +01:00
parent 5ee6d375c0
commit 801f070a7d

View file

@ -41,22 +41,22 @@
namespace lib { namespace lib {
namespace { // implementation details namespace nifty { // implementation details
template<class X> template<class X>
struct NiftyHolder struct Holder
{ {
static uint accessed_; static uint accessed_;
static char content_[sizeof(X)]; static char content_[sizeof(X)];
NiftyHolder() Holder()
{ {
if (!accessed_) if (!accessed_)
new(content_) X(); new(content_) X();
++accessed_; ++accessed_;
} }
~NiftyHolder() ~Holder()
{ {
--accessed_; --accessed_;
if (0==accessed_) if (0==accessed_)
@ -73,12 +73,12 @@ namespace lib {
}; };
template<class X> template<class X>
uint NiftyHolder<X>::accessed_; uint Holder<X>::accessed_;
template<class X> template<class X>
char NiftyHolder<X>::content_[sizeof(X)]; char Holder<X>::content_[sizeof(X)];
} // (End) implementation details } // (End) nifty implementation details
@ -100,14 +100,14 @@ namespace lib {
Monitor& Monitor&
getPerClassMonitor() getPerClassMonitor()
{ {
static NiftyHolder<Monitor> __used_here; static nifty::Holder<Monitor> __used_here;
return __used_here.get(); return __used_here.get();
} }
public: public:
ClassLock() : Lock (getPerClassMonitor()) {} ClassLock() : Lock (getPerClassMonitor()) {}
uint use_count() { return NiftyHolder<Monitor>::accessed_; } uint use_count() { return nifty::Holder<Monitor>::accessed_; }
}; };