// Singleton.cpp // $Id$ #if !defined (ACE_SINGLETON_C) #define ACE_SINGLETON_C #define ACE_BUILD_DLL #include "ace/Singleton.h" #include "ace/Synch_T.h" #if !defined (__ACE_INLINE__) #include "ace/Singleton.i" #endif /* __ACE_INLINE__ */ template void ACE_Singleton::dump (void) const { ACE_TRACE ("ACE_Singleton::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) ACE_DEBUG ((LM_DEBUG, "instance_ = %x", this->instance_)); ace_singleton_lock_.dump (); ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ } template TYPE * ACE_Singleton::instance (void) { ACE_TRACE ("ACE_Singleton::instance"); #if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) // Pointer to the Singleton instance. This works around a bug with // G++... static TYPE *instance_ = 0; // Lock the creation of the singleton. This works around a // "feature" of G++... ;-) static LOCK ace_singleton_lock_; // Perform the Double-Check pattern... if (instance_ == 0) { ACE_GUARD_RETURN (LOCK, ace_mon, ace_singleton_lock_, 0); if (instance_ == 0) ACE_NEW_RETURN (instance_, TYPE, 0); } return instance_; #else // Perform the Double-Check pattern... if (ACE_Singleton::instance_ == 0) { ACE_GUARD_RETURN (LOCK, ace_mon, (ACE_Singleton::ace_singleton_lock_), 0); if (ACE_Singleton::instance_ == 0) ACE_NEW_RETURN ((ACE_Singleton::instance_), TYPE, 0); } return ACE_Singleton::instance_; #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ } #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) // Pointer to the Singleton instance. template TYPE * ACE_Singleton::instance_ = 0; // Lock the creation of the singleton. template LOCK ACE_Singleton::ace_singleton_lock_; #endif /* !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) */ #endif /* ACE_SINGLETON_C */