#include <Singleton.h>
Collaboration diagram for ACE_DLL_Singleton_T:

Public Methods | |
| const ACE_TCHAR * | dll_name (void) |
| const ACE_TCHAR * | name (void) |
Static Public Methods | |
| TYPE * | instance (void) |
| Global access point to the Singleton. More... | |
| void | close (void) |
| Explicitly delete the Singleton instance. More... | |
| void | close_singleton (void) |
| void | dump (void) |
| Dump the state of the object. More... | |
Protected Methods | |
| ACE_DLL_Singleton_T (void) | |
| Default constructor. More... | |
| ~ACE_DLL_Singleton_T (void) | |
| Destructor. More... | |
Static Protected Methods | |
| ACE_DLL_Singleton_T< TYPE, ACE_LOCK > *& | instance_i (void) |
| Get pointer to the singleton instance. More... | |
Protected Attributes | |
| TYPE | instance_ |
| Contained instance. More... | |
Static Protected Attributes | |
| ACE_DLL_Singleton_T< TYPE, ACE_LOCK > * | singleton_ = 0 |
| Pointer to the Singleton instance. More... | |
This version of ACE_Singleton should be used for singletons that live in a dll loaded either directly by ACE_DLL or indirectly by the ACE Service Configuration framework. Whenever ACE_DLL is ready to actually unload the dll, ACE_DLL_Singleton based dlls associated with that dll will be destroyed first. In fact, any singleton can safely use ACE_DLL_Singleton, even those that don't live in dlls. In that case, the singleton will be destroyed at normal program shutdown.
The only additional requirement is that the contained class export name() and dll_name() methods. See ACE_DLL_Singleton_Adapter_T below for a convenient example of how to satisfy this requirement for the dll_name().
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 263 of file Singleton.h.
|
||||||||||
|
Default constructor.
Definition at line 30 of file Singleton.i.
00031 {
00032 }
|
|
||||||||||
|
Destructor.
Definition at line 35 of file Singleton.i.
00036 {
00037 }
|
|
||||||||||
|
Explicitly delete the Singleton instance.
Definition at line 478 of file Singleton.cpp. References ACE_TRACE, and instance_i. Referenced by close_singleton.
00479 {
00480 ACE_TRACE ("ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::close");
00481
00482 ACE_DLL_Singleton_T<TYPE, ACE_LOCK> *&singleton =
00483 ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance_i ();
00484
00485 delete singleton;
00486 singleton = 0;
00487 }
|
|
||||||||||
|
Definition at line 490 of file Singleton.cpp. References ACE_TRACE, and close.
00491 {
00492 ACE_TRACE ("ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::close_singleton");
00493 ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::close ();
00494 }
|
|
||||||||||
|
Definition at line 497 of file Singleton.cpp. References instance.
00498 {
00499 return this->instance ()->dll_name ();
00500 }
|
|
||||||||||
|
Dump the state of the object.
Definition at line 398 of file Singleton.cpp. References ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, instance_i, and LM_DEBUG.
00399 {
00400 ACE_TRACE ("ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::dump");
00401
00402 #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00403 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("instance_ = %x"),
00404 ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance_i ()));
00405 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00406 #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
00407 }
|
|
||||||||||
|
Global access point to the Singleton.
Definition at line 427 of file Singleton.cpp. References ACE_GUARD_RETURN, ACE_NEW_RETURN, ACE_TRACE, ACE_Framework_Repository::instance, instance_, instance_i, ACE_Framework_Repository::register_component, ACE_Object_Manager::shutting_down, and ACE_Object_Manager::starting_up. Referenced by dll_name, and name.
00428 {
00429 ACE_TRACE ("ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance");
00430
00431 ACE_DLL_Singleton_T<TYPE, ACE_LOCK> *&singleton =
00432 ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance_i ();
00433
00434 // Perform the Double-Check pattern...
00435 if (singleton == 0)
00436 {
00437 if (ACE_Object_Manager::starting_up () ||
00438 ACE_Object_Manager::shutting_down ())
00439 {
00440 // The program is still starting up, and therefore assumed
00441 // to be single threaded. There's no need to double-check.
00442 // Or, the ACE_Object_Manager instance has been destroyed,
00443 // so the preallocated lock is not available. Either way,
00444 // don't register for destruction with the
00445 // ACE_Object_Manager: we'll have to leak this instance.
00446
00447 ACE_NEW_RETURN (singleton, (ACE_DLL_Singleton_T<TYPE, ACE_LOCK>),
00448 0);
00449 }
00450 else
00451 {
00452 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00453 // Obtain a lock from the ACE_Object_Manager. The pointer
00454 // is static, so we only obtain one per
00455 // ACE_Unmanaged_Singleton instantiation.
00456 static ACE_LOCK *lock = 0;
00457 if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
00458 // Failed to acquire the lock!
00459 return 0;
00460
00461 ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0);
00462 #endif /* ACE_MT_SAFE */
00463
00464 if (singleton == 0)
00465 ACE_NEW_RETURN (singleton,
00466 (ACE_DLL_Singleton_T<TYPE, ACE_LOCK>),
00467 0);
00468 }
00469 //ACE_REGISTER_FRAMEWORK_COMPONENT(ACE_DLL_Singleton<TYPE,ACE_LOCK>, singleton);
00470 ACE_Framework_Repository::instance ()->register_component
00471 (new ACE_Framework_Component_T<ACE_DLL_Singleton_T<TYPE, ACE_LOCK> > (singleton));
00472 }
00473
00474 return &singleton->instance_;
00475 }
|
|
||||||||||
|
Get pointer to the singleton instance.
Definition at line 411 of file Singleton.cpp. References ACE_TRACE, and singleton_. Referenced by close, dump, and instance.
00412 {
00413 ACE_TRACE ("ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance_i");
00414
00415 #if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00416 // Pointer to the Singleton instance. This works around a bug with
00417 // G++ and it's (mis-)handling of templates and statics...
00418 static ACE_DLL_Singleton_T<TYPE, ACE_LOCK> *singleton_ = 0;
00419
00420 return singleton_;
00421 #else
00422 return ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::singleton_;
00423 #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
00424 }
|
|
||||||||||
|
Definition at line 503 of file Singleton.cpp. References instance.
00504 {
00505 return this->instance ()->name ();
00506 }
|
|
|||||
|
Contained instance.
Definition at line 291 of file Singleton.h. Referenced by instance. |
|
|||||
|
Pointer to the Singleton instance.
Definition at line 394 of file Singleton.cpp. Referenced by instance_i. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002