Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_TSS_Singleton Class Template Reference

TAO-specific Singleton class. More...

#include <TAO_Singleton.h>

Inheritance diagram for TAO_TSS_Singleton:

Inheritance graph
[legend]
Collaboration diagram for TAO_TSS_Singleton:

Collaboration graph
[legend]
List of all members.

Public Methods

virtual void cleanup (void *param=0)
 Cleanup method, used by <ace_cleanup_destroyer> to destroy the singleton. More...


Static Public Methods

TYPE * instance (void)
 Global access point to the Singleton. More...

void dump (void)
 Dump the state of the object. More...


Protected Methods

 TAO_TSS_Singleton (void)
 Default constructor. More...

 ACE_TSS_TYPE (TYPE) instance_
 Contained instance. More...


Static Protected Methods

TAO_TSS_Singleton< TYPE, ACE_LOCK > *& instance_i (void)
 Get pointer to the TAO TSS Singleton instance. More...


Static Protected Attributes

TAO_TSS_Singleton< TYPE, ACE_LOCK > * singleton_ = 0
 Pointer to the Singleton (ACE_Cleanup) instance. More...


Private Methods

void operator= (const TAO_TSS_Singleton< TYPE, ACE_LOCK > &)
 TAO_TSS_Singleton (const TAO_TSS_Singleton< TYPE, ACE_LOCK > &)

Detailed Description

template<class TYPE, class ACE_LOCK>
class TAO_TSS_Singleton< TYPE, ACE_LOCK >

TAO-specific Singleton class.

TAO_Singletons are used by TAO to register TAO-specific singleton instances with the TAO_Object_Manager. This ensures that TAO singletons are isolated from ACE's Object_Manager, thus allowing TAO to be safely dynamically unloaded.

Definition at line 83 of file TAO_Singleton.h.


Constructor & Destructor Documentation

template<class TYPE, class ACE_LOCK>
ACE_INLINE TAO_TSS_Singleton< TYPE, ACE_LOCK >::TAO_TSS_Singleton void    [protected]
 

Default constructor.

Definition at line 15 of file TAO_Singleton.inl.

00016 {
00017 }

template<class TYPE, class ACE_LOCK>
TAO_TSS_Singleton< TYPE, ACE_LOCK >::TAO_TSS_Singleton const TAO_TSS_Singleton< TYPE, ACE_LOCK > &    [private]
 


Member Function Documentation

template<class TYPE, class ACE_LOCK>
TAO_TSS_Singleton< TYPE, ACE_LOCK >::ACE_TSS_TYPE TYPE    [protected]
 

Contained instance.

template<class TYPE, class ACE_LOCK>
void TAO_TSS_Singleton< TYPE, ACE_LOCK >::cleanup void *    param = 0 [virtual]
 

Cleanup method, used by <ace_cleanup_destroyer> to destroy the singleton.

Reimplemented from ACE_Cleanup.

Definition at line 202 of file TAO_Singleton.cpp.

References instance_i.

00203 {
00204   delete this;
00205   TAO_TSS_Singleton<TYPE, ACE_LOCK>::instance_i () = 0;
00206 }

template<class TYPE, class ACE_LOCK>
void TAO_TSS_Singleton< TYPE, ACE_LOCK >::dump void    [static]
 

Dump the state of the object.

Definition at line 123 of file TAO_Singleton.cpp.

References ACE_DEBUG, ACE_END_DUMP, ACE_TEXT, ACE_TRACE, instance_i, and LM_DEBUG.

00124 {
00125   ACE_TRACE ("TAO_TSS_Singleton<TYPE, ACE_LOCK>::dump");
00126 
00127 #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00128   ACE_DEBUG ((LM_DEBUG,  ACE_TEXT ("instance_ = %x"),
00129               TAO_TSS_Singleton<TYPE, ACE_LOCK>::instance_i ()));
00130   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00131 #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
00132 }

template<class TYPE, class ACE_LOCK>
TYPE * TAO_TSS_Singleton< TYPE, ACE_LOCK >::instance void    [static]
 

Global access point to the Singleton.

Definition at line 149 of file TAO_Singleton.cpp.

References ACE_GUARD_RETURN, ACE_NEW_RETURN, ACE_TRACE, ACE_TSS_GET, TAO_Singleton_Manager::at_exit, instance_i, TAO_Singleton_Manager::shutting_down, and TAO_Singleton_Manager::starting_up.

Referenced by TAO_ORB_Core::default_environment, TAO_Policy_Current::implementation, and TAO_default_environment.

00150 {
00151   ACE_TRACE ("TAO_TSS_Singleton<TYPE, ACE_LOCK>::instance");
00152 
00153   TAO_TSS_Singleton<TYPE, ACE_LOCK> *&singleton =
00154     TAO_TSS_Singleton<TYPE, ACE_LOCK>::instance_i ();
00155 
00156   // Perform the Double-Check pattern...
00157   if (singleton == 0)
00158     {
00159       if (TAO_Singleton_Manager::starting_up () ||
00160           TAO_Singleton_Manager::shutting_down ())
00161         {
00162           // The program is still starting up, and therefore assumed
00163           // to be single threaded.  There's no need to double-check.
00164           // Or, the TAO_Singleton_Manager instance has been destroyed,
00165           // so the preallocated lock is not available.  Either way,
00166           // don't register for destruction with the
00167           // TAO_Singleton_Manager:  we'll have to leak this instance.
00168 
00169           ACE_NEW_RETURN (singleton, (TAO_TSS_Singleton<TYPE, ACE_LOCK>), 0);
00170         }
00171       else
00172         {
00173 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00174           // Obtain a lock from the ACE_Object_Manager.  The pointer
00175           // is static, so we only obtain one per TAO_Singleton
00176           // instantiation.
00177           static ACE_LOCK *lock = 0;
00178           if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
00179             // Failed to acquire the lock!
00180             return 0;
00181 
00182           ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0);
00183 
00184           if (singleton == 0)
00185             {
00186 #endif /* ACE_MT_SAFE */
00187               ACE_NEW_RETURN (singleton, (TAO_TSS_Singleton<TYPE, ACE_LOCK>),
00188                               0);
00189 
00190               // Register for destruction with TAO_Singleton_Manager.
00191               TAO_Singleton_Manager::at_exit (singleton);
00192 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00193             }
00194 #endif /* ACE_MT_SAFE */
00195         }
00196     }
00197 
00198   return ACE_TSS_GET (&singleton->instance_, TYPE);
00199 }

template<class TYPE, class ACE_LOCK>
TAO_TSS_Singleton< TYPE, ACE_LOCK > *& TAO_TSS_Singleton< TYPE, ACE_LOCK >::instance_i void    [static, protected]
 

Get pointer to the TAO TSS Singleton instance.

Definition at line 135 of file TAO_Singleton.cpp.

References singleton_.

Referenced by cleanup, dump, and instance.

00136 {
00137 #if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00138   // Pointer to the Singleton instance.  This works around a bug with
00139   // G++ and it's (mis-)handling of templates and statics...
00140   static TAO_TSS_Singleton<TYPE, ACE_LOCK> *singleton_ = 0;
00141 
00142   return singleton_;
00143 #else
00144   return TAO_TSS_Singleton<TYPE, ACE_LOCK>::singleton_;
00145 #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
00146 }

template<class TYPE, class ACE_LOCK>
void TAO_TSS_Singleton< TYPE, ACE_LOCK >::operator= const TAO_TSS_Singleton< TYPE, ACE_LOCK > &    [private]
 


Member Data Documentation

template<class TYPE, class ACE_LOCK>
TAO_TSS_Singleton< TYPE, ACE_LOCK > * TAO_TSS_Singleton< TYPE, ACE_LOCK >::singleton_ = 0 [static, protected]
 

Pointer to the Singleton (ACE_Cleanup) instance.

Definition at line 118 of file TAO_Singleton.cpp.

Referenced by instance_i.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:45:35 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002