#include <Singleton.h>
Inheritance diagram for ACE_Unmanaged_Singleton:


Static Public Methods | |
| TYPE * | instance (void) |
| Global access point to the Singleton. More... | |
| void | close (void) |
| Explicitly delete the Singleton instance. More... | |
| void | dump (void) |
| Dump the state of the object. More... | |
Protected Methods | |
| ACE_Unmanaged_Singleton (void) | |
| Default constructor. More... | |
Static Protected Methods | |
| ACE_Unmanaged_Singleton< TYPE, ACE_LOCK > *& | instance_i (void) |
| Get pointer to the Singleton instance. More... | |
Static Protected Attributes | |
| ACE_Unmanaged_Singleton< TYPE, ACE_LOCK > * | singleton_ = 0 |
| Pointer to the Singleton (ACE_Cleanup) instance. More... | |
This version of ACE_Singleton can be used if, for example, its DLL will be unloaded before the ACE_Object_Manager destroys the instance. Unlike with ACE_Singleton, the application is responsible for explicitly destroying the instance after it is no longer needed (if it wants to avoid memory leaks, at least). The close() static member function must be used to explicitly destroy the Singleton. Usage is the same as for ACE_Singleton, but note that if you you declare a friend, the friend class must still be an *ACE_Singleton*<T, [ACE_LOCK]>, not an ACE_Unmanaged_Singleton.
Definition at line 123 of file Singleton.h.
|
||||||||||
|
Default constructor.
Definition at line 15 of file Singleton.i.
00016 {
00017 }
|
|
||||||||||
|
Explicitly delete the Singleton instance.
Definition at line 195 of file Singleton.cpp. References ACE_Singleton::cleanup, and instance_i.
00196 {
00197 ACE_Unmanaged_Singleton<TYPE, ACE_LOCK> *&singleton =
00198 ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance_i ();
00199
00200 if (singleton)
00201 {
00202 singleton->cleanup ();
00203 ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance_i () = 0;
00204 }
00205 }
|
|
||||||||||
|
Dump the state of the object.
Reimplemented from ACE_Singleton. Definition at line 120 of file Singleton.cpp. References ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, instance_i, and LM_DEBUG.
00121 {
00122 ACE_TRACE ("ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::dump");
00123
00124 #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00125 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("instance_ = %x"),
00126 ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance_i ()));
00127 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00128 #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
00129 }
|
|
||||||||||
|
Global access point to the Singleton.
Reimplemented from ACE_Singleton. Definition at line 147 of file Singleton.cpp. References ACE_GUARD_RETURN, ACE_NEW_RETURN, ACE_TRACE, ACE_Singleton::instance_, instance_i, ACE_Object_Manager::shutting_down, and ACE_Object_Manager::starting_up.
00148 {
00149 ACE_TRACE ("ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance");
00150
00151 ACE_Unmanaged_Singleton<TYPE, ACE_LOCK> *&singleton =
00152 ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance_i ();
00153
00154 // Perform the Double-Check pattern...
00155 if (singleton == 0)
00156 {
00157 if (ACE_Object_Manager::starting_up () ||
00158 ACE_Object_Manager::shutting_down ())
00159 {
00160 // The program is still starting up, and therefore assumed
00161 // to be single threaded. There's no need to double-check.
00162 // Or, the ACE_Object_Manager instance has been destroyed,
00163 // so the preallocated lock is not available. Either way,
00164 // don't register for destruction with the
00165 // ACE_Object_Manager: we'll have to leak this instance.
00166
00167 ACE_NEW_RETURN (singleton, (ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>),
00168 0);
00169 }
00170 else
00171 {
00172 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00173 // Obtain a lock from the ACE_Object_Manager. The pointer
00174 // is static, so we only obtain one per
00175 // ACE_Unmanaged_Singleton instantiation.
00176 static ACE_LOCK *lock = 0;
00177 if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
00178 // Failed to acquire the lock!
00179 return 0;
00180
00181 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0);
00182 #endif /* ACE_MT_SAFE */
00183
00184 if (singleton == 0)
00185 ACE_NEW_RETURN (singleton,
00186 (ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>),
00187 0);
00188 }
00189 }
00190
00191 return &singleton->instance_;
00192 }
|
|
||||||||||
|
Get pointer to the Singleton instance.
Reimplemented from ACE_Singleton. Definition at line 133 of file Singleton.cpp. References singleton_. Referenced by close, dump, and instance.
00134 {
00135 #if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00136 // Pointer to the Singleton instance. This works around a bug with
00137 // G++ and it's (mis-)handling of templates and statics...
00138 static ACE_Unmanaged_Singleton<TYPE, ACE_LOCK> *singleton_ = 0;
00139
00140 return singleton_;
00141 #else
00142 return ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::singleton_;
00143 #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
00144 }
|
|
|||||
|
Pointer to the Singleton (ACE_Cleanup) instance.
Reimplemented from ACE_Singleton. Definition at line 116 of file Singleton.cpp. Referenced by instance_i. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002