summaryrefslogtreecommitdiff
path: root/ace/Singleton.h
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-14 15:25:12 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-14 15:25:12 +0000
commit04a062314bfcda6a53204bbddf9ad9c579fa3126 (patch)
tree043c42056ea2704243da8004289676889abb1eba /ace/Singleton.h
parent7986e98bcc4960a30e97ea92c3a7eb157581364f (diff)
downloadATCD-04a062314bfcda6a53204bbddf9ad9c579fa3126.tar.gz
ChangeLogTag: Wed Jul 14 10:22:29 1999 David L. Levine <levine@cs.wustl.edu>
Diffstat (limited to 'ace/Singleton.h')
-rw-r--r--ace/Singleton.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/ace/Singleton.h b/ace/Singleton.h
index 14bb6461ccb..9bef9acf126 100644
--- a/ace/Singleton.h
+++ b/ace/Singleton.h
@@ -104,6 +104,45 @@ protected:
};
template <class TYPE, class ACE_LOCK>
+class ACE_Unmanaged_Singleton : public ACE_Singleton <TYPE, ACE_LOCK>
+{
+ // = TITLE
+ // Same as <ACE_Singleton>, except does _not_ register with
+ // <ACE_Object_Manager> for destruction.
+ //
+ // = DESCRIPTION
+ // This version of <ACE_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.
+ //
+public:
+ static TYPE *instance (void);
+ // Global access point to the Singleton.
+
+ static void close (void);
+ // Explicitly delete the Singleton instance.
+
+ static void dump (void);
+ // Dump the state of the object.
+
+protected:
+ ACE_Unmanaged_Singleton (void);
+ // Default constructor.
+
+#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
+ static ACE_Unmanaged_Singleton<TYPE, ACE_LOCK> *singleton_;
+ // Pointer to the Singleton (ACE_Cleanup) instance.
+#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
+
+ static ACE_Unmanaged_Singleton<TYPE, ACE_LOCK> *&instance_i (void);
+ // Get pointer to the Singleton instance.
+};
+
+template <class TYPE, class ACE_LOCK>
class ACE_TSS_Singleton : public ACE_Cleanup
{
// = TITLE
@@ -149,6 +188,46 @@ protected:
// Get pointer to the TSS Singleton instance.
};
+template <class TYPE, class ACE_LOCK>
+class ACE_Unmanaged_TSS_Singleton : public ACE_TSS_Singleton <TYPE, ACE_LOCK>
+{
+ // = TITLE
+ // Same as <ACE_TSS_Singleton>, except does _not_ register with
+ // <ACE_Object_Manager> for destruction.
+ //
+ // = DESCRIPTION
+ // 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.
+ //
+public:
+ static TYPE *instance (void);
+ // Global access point to the Singleton.
+
+ static void close (void);
+ // Explicitly delete the Singleton instance.
+
+ static void dump (void);
+ // Dump the state of the object.
+
+protected:
+ ACE_Unmanaged_TSS_Singleton (void);
+ // Default constructor.
+
+#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
+ static ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK> *singleton_;
+ // Pointer to the Singleton (ACE_Cleanup) instance.
+#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
+
+ static ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK> *&instance_i (void);
+ // Get pointer to the Singleton instance.
+};
+
#if defined (__ACE_INLINE__)
#include "ace/Singleton.i"
#endif /* __ACE_INLINE__ */