#include <Singleton.h>
Inheritance diagram for ACE_Unmanaged_TSS_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_TSS_Singleton (void) | |
| Default constructor. More... | |
Static Protected Methods | |
| ACE_Unmanaged_TSS_Singleton< TYPE, ACE_LOCK > *& | instance_i (void) |
| Get pointer to the Singleton instance. More... | |
Static Protected Attributes | |
| ACE_Unmanaged_TSS_Singleton< TYPE, ACE_LOCK > * | singleton_ = 0 |
| Pointer to the Singleton (ACE_Cleanup) instance. More... | |
This version of ACE_TSS_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.
Definition at line 213 of file Singleton.h.
|
||||||||||
|
Default constructor.
Definition at line 25 of file Singleton.i.
00026 {
00027 }
|
|
||||||||||
|
Explicitly delete the singleton instance.
Definition at line 370 of file Singleton.cpp. References ACE_TSS_Singleton::cleanup, and instance_i.
00371 {
00372 ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK> *&singleton =
00373 ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::instance_i ();
00374
00375 if (singleton)
00376 singleton->cleanup ();
00377 }
|
|
||||||||||
|
Dump the state of the object.
Reimplemented from ACE_TSS_Singleton. Definition at line 294 of file Singleton.cpp. References ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, instance_i, and LM_DEBUG.
00295 {
00296 ACE_TRACE ("ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::dump");
00297
00298 #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00299 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("instance_ = %x"),
00300 ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::instance_i ()));
00301 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00302 #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
00303 }
|
|
||||||||||
|
Global access point to the singleton.
Reimplemented from ACE_TSS_Singleton. Definition at line 321 of file Singleton.cpp. References ACE_GUARD_RETURN, ACE_NEW_RETURN, ACE_TRACE, ACE_TSS_GET, instance_i, ACE_Object_Manager::shutting_down, and ACE_Object_Manager::starting_up.
00322 {
00323 ACE_TRACE ("ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::instance");
00324
00325 ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK> *&singleton =
00326 ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::instance_i ();
00327
00328 // Perform the Double-Check pattern...
00329 if (singleton == 0)
00330 {
00331 if (ACE_Object_Manager::starting_up () ||
00332 ACE_Object_Manager::shutting_down ())
00333 {
00334 // The program is still starting up, and therefore assumed
00335 // to be single threaded. There's no need to double-check.
00336 // Or, the ACE_Object_Manager instance has been destroyed,
00337 // so the preallocated lock is not available. Either way,
00338 // don't register for destruction with the
00339 // ACE_Object_Manager: we'll have to leak this instance.
00340
00341 ACE_NEW_RETURN (singleton,
00342 (ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>),
00343 0);
00344 }
00345 else
00346 {
00347 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00348 // Obtain a lock from the ACE_Object_Manager. The pointer
00349 // is static, so we only obtain one per
00350 // ACE_Unmanaged_Singleton instantiation.
00351 static ACE_LOCK *lock = 0;
00352 if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
00353 // Failed to acquire the lock!
00354 return 0;
00355
00356 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0);
00357 #endif /* ACE_MT_SAFE */
00358
00359 if (singleton == 0)
00360 ACE_NEW_RETURN (singleton,
00361 (ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>),
00362 0);
00363 }
00364 }
00365
00366 return ACE_TSS_GET (&singleton->instance_, TYPE);
00367 }
|
|
||||||||||
|
Get pointer to the Singleton instance.
Reimplemented from ACE_TSS_Singleton. Definition at line 307 of file Singleton.cpp. References singleton_. Referenced by close, dump, and instance.
00308 {
00309 #if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00310 // Pointer to the Singleton instance. This works around a bug with
00311 // G++ and it's (mis-)handling of templates and statics...
00312 static ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK> *singleton_ = 0;
00313
00314 return singleton_;
00315 #else
00316 return ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::singleton_;
00317 #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
00318 }
|
|
|||||
|
Pointer to the Singleton (ACE_Cleanup) instance.
Reimplemented from ACE_TSS_Singleton. Definition at line 386 of file Singleton.cpp. Referenced by instance_i. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002