![]() |
Rosetta Utilities
2015.09
|
SingletonBase is meant to serve as a base class for singleton classes in Rosetta handling the initialization of the singleton in a thread-safe way. More...
#include <SingletonBase.hh>
Public Member Functions | |
SingletonBase () | |
public constructor (the derived class must have a private constructor, of course). More... | |
Static Public Member Functions | |
static T * | get_instance () |
Safely instantiate a singleton class in a (possibly) multithreaded context. More... | |
Private Member Functions | |
SingletonBase (SingletonBase< T > const &) | |
Private, unimplemented copy constructor – uncopyable. More... | |
SingletonBase< T > const & | operator= (SingletonBase< T > const &rhs) |
Private, unimplemented assignment operator – uncopyable. More... | |
template<> | |
WriteableCacheableDataFactory * | instance_ (0) |
template<> | |
MessageListenerFactory * | instance_ (0) |
template<> | |
FallbackConfigurationFactory * | instance_ (0) |
template<> | |
ResourceLoaderFactory * | instance_ (0) |
template<> | |
ResourceLocatorFactory * | instance_ (0) |
template<> | |
ResourceManager * | instance_ (0) |
template<> | |
ResourceManagerFactory * | instance_ (0) |
template<> | |
ResourceOptionsFactory * | instance_ (0) |
template<> | |
QuaternionGridManager * | instance_ (0) |
template<> | |
Inline_File_Provider * | instance_ (0) |
Static Private Attributes | |
static T * | instance_ |
SingletonBase is meant to serve as a base class for singleton classes in Rosetta handling the initialization of the singleton in a thread-safe way.
The derived class must a) implement a private, static function: T * create_singleton_instance() so that the SingletonBase class can invoke this function, and b) declare the SingletonBase class to be a friend, so that it can invoke this function The .cc file in which the derived singleton must be put will need to include the definitions for the two static data members, instance_ and singleton_mutex_.
|
inline |
public constructor (the derived class must have a private constructor, of course).
|
private |
Private, unimplemented copy constructor – uncopyable.
|
inlinestatic |
Safely instantiate a singleton class in a (possibly) multithreaded context.
In the non-multithreaded case, this simply checks the singleton's instance member; in the multithreaded case, it checks the instance member, then it obtains the singleton's instance-creation mutex, then it checks the instance member again, to ensure that no other thread has already created the instance, it creates the instance, and then it releases the mutex.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Private, unimplemented assignment operator – uncopyable.
|
staticprivate |