summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-08-07 22:44:37 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-08-07 22:44:37 +0000
commit2a27327521cdb2bddf3da945961c471bf57961b9 (patch)
tree7c5a7b288f3d8de3427b3dd8ff80a83f01eb789f
parent5cc1286c981238487e2af98c039e80279d6cf47d (diff)
downloadATCD-2a27327521cdb2bddf3da945961c471bf57961b9.tar.gz
*** empty log message ***
-rw-r--r--ace/Singleton.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/ace/Singleton.h b/ace/Singleton.h
index f8bfa8ef8de..0576afd07da 100644
--- a/ace/Singleton.h
+++ b/ace/Singleton.h
@@ -41,6 +41,25 @@ class ACE_Singleton : public ACE_Cleanup
// provided. <ACE_Singleton> provides one so that TYPE doesn't
// need to.
//
+ // If you want to make sure that only the singleton instance of
+ // <T> is created, and that users cannot create their own
+ // instances of <T>, do the following to class <T>:
+ //
+ // (a) Make the constructor of <T> private (or protected)
+ // (b) Make Singleton a friend of <T>
+ //
+ // Here is an example:
+ //
+ // class foo
+ // {
+ // friend class ACE_Singleton<foo, ACE_Null_Mutex>;
+ // private:
+ // foo () { cout << "foo constructed" << endl; }
+ // ~foo () { cout << "foo destroyed" << endl; }
+ // };
+ //
+ // typedef ACE_Singleton<foo, ACE_Null_Mutex> FOO;
+ //
// NOTE: the best types to use for ACE_LOCK are
// ACE_Recursive_Thread_Mutex and ACE_Null_Mutex.
// ACE_Recursive_Thread_Mutex should be used in multi-threaded
@@ -52,6 +71,7 @@ class ACE_Singleton : public ACE_Cleanup
// and ACE_Null_Mutex instances are used for all ACE_Singleton
// instantiations. However, other types of locks are allocated
// per ACE_Singleton instantiation.
+ //
public:
static TYPE *instance (void);
// Global access point to the Singleton.