diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-05-15 03:00:52 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-05-15 03:00:52 +0000 |
commit | fee951cea2abb0770870fb273d21b4cbe06f20d2 (patch) | |
tree | 419f029ad1b04cdecd8147b71e4b992e9e1342dc /ace/Singleton.cpp | |
parent | d4e30a27d69fe8e2d297688931a15abdac933da8 (diff) | |
download | ATCD-fee951cea2abb0770870fb273d21b4cbe06f20d2.tar.gz |
*** empty log message ***
Diffstat (limited to 'ace/Singleton.cpp')
-rw-r--r-- | ace/Singleton.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/ace/Singleton.cpp b/ace/Singleton.cpp index a715f776d85..cffdfbe0080 100644 --- a/ace/Singleton.cpp +++ b/ace/Singleton.cpp @@ -77,13 +77,13 @@ ACE_Singleton<TYPE, LOCK>::instance (TYPE *new_instance) { ACE_TRACE ("ACE_Singleton::set_instance"); - TYPE *&singleton = ACE_Singleton<TYPE, LOCK>::instance_i (); ACE_GUARD_RETURN (LOCK, ace_mon, (ACE_Singleton<TYPE, LOCK>::singleton_lock_i ()), 0); + TYPE *&singleton = ACE_Singleton<TYPE, LOCK>::instance_i (); TYPE *old_instance = singleton; singleton = new_instance; - return singleton; + return old_instance; } #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) @@ -160,6 +160,20 @@ ACE_SingletonEx<TYPE, LOCK, MEMORY>::instance (void) return singleton->ts_object (); } +template <class TYPE, class LOCK, ACE_SingletonEx_Strategy MEMORY> TYPE * +ACE_Singleton<TYPE, LOCK, MEMORY>::instance (TYPE *new_instance) +{ + ACE_TRACE ("ACE_Singleton<TYPE, LOCK, MEMORY>::set_instance"); + + ACE_GUARD_RETURN (LOCK, ace_mon, (ACE_SingletonEx<TYPE, LOCK, MEMORY>::singleton_lock_i ()), 0); + + TYPE *&singleton = ACE_Singleton<TYPE, LOCK, MEMORY>::instance_i (); + TYPE *old_instance = singleton; + singleton = new_instance; + + return old_instance; +} + #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) // Pointer to the Singleton instance. template <class TYPE, class LOCK, ACE_SingletonEx_Strategy MEMORY> TYPE * |