Added an InitGlobalMutexes to enforce early construction and hence late destruction of singleton mutexes.

This commit is contained in:
Robert Osfield 2010-02-19 09:02:24 +00:00
parent b5c5ae7185
commit 530c947c94
3 changed files with 14 additions and 2 deletions

View File

@ -94,6 +94,18 @@ OpenThreads::Mutex* Observer::getGlobalObserverMutex()
return s_ReferencedGlobalMutext.get();
}
// helper class for forcing the global mutex to be constructed when the library is loaded.
struct InitGlobalMutexes
{
InitGlobalMutexes()
{
Referenced::getGlobalReferencedMutex();
Observer::getGlobalObserverMutex();
}
};
static InitGlobalMutexes s_initGlobalMutexes;
#if !defined(_OSG_REFERENCED_USE_ATOMIC_OPERATIONS)
static bool s_useThreadSafeReferenceCounting = getenv("OSG_THREAD_SAFE_REF_UNREF")!=0;
#endif