#include <singletonfactory.hpp>

Actually this is a Functor object, which could be placed into a static field of the Singleton (target) class or used directly.
Definition at line 60 of file singletonfactory.hpp.
Public Member Functions | |
| SI & | operator() () |
| Interface to be used by SingletonFactory's clients. | |
Private Types | |
|
typedef Threading< SI > ::VolatileType | SType |
| typedef Threading< SI >::Lock | ThreadLock |
Static Private Member Functions | |
| static void | destroy () |
Static Private Attributes | |
| static bool | isDead_ |
| static SType * | pInstance_ |
| static void lumiera::SingletonFactory< SI, Create, Life, Threading >::destroy | ( | ) | [inline, static, private] |
For internal use only.
helper used to delegate destroying the single instance to the Create policy, at the same time allowing the Life policy to control the point in the Application lifecycle when the destruction of this instance occures.
Definition at line 99 of file singletonfactory.hpp.
00100 { 00101 TRACE (singleton, "Singleton: triggering destruction"); 00102 00103 REQUIRE (!isDead_); 00104 Create<SI>::destroy (pInstance_); 00105 pInstance_ = 0; 00106 isDead_ = true; 00107 }

| SI& lumiera::SingletonFactory< SI, Create, Life, Threading >::operator() | ( | ) | [inline] |
Interface to be used by SingletonFactory's clients.
Manages internally the instance creation, lifecycle and access handling in a multithreaded context.
Reimplemented in lumiera::test::MockInjector< SI >.
Definition at line 73 of file singletonfactory.hpp.
00074 { 00075 if (!pInstance_) 00076 { 00077 ThreadLock guard SIDEEFFECT; 00078 if (!pInstance_) 00079 { 00080 if (isDead_) 00081 { 00082 Life<SI>::onDeadReference(); 00083 isDead_ = false; 00084 } 00085 pInstance_ = Create<SI>::create(); 00086 Life<SI>::scheduleDelete (&destroy); 00087 } } 00088 ENSURE (pInstance_); 00089 ENSURE (!isDead_); 00090 return *pInstance_; 00091 }
1.5.6