Main Page   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members  

Singleton Class Template Reference

#include <Singleton.h>

Inheritance diagram for Singleton:

NonCopyable List of all members.

Static Public Methods

T * instance ()

Detailed Description

template<class T, class InstantiationPolicy = LazyInstantiation, class LockType = FastMutex>
class ZThread::Singleton< T, InstantiationPolicy, LockType >

Author:
Eric Crahen <crahen@cse.buffalo.edu>
Date:
<2002-06-19T07:21:52-0400>
Version:
2.2.0
Based on the work of John Vlissidles in his book 'Pattern Hatching' an article by Douglas Schmidtt on double-checked locking and policy templates described by Andrei Alexandrescu.

This is a thread safe wrapper for creating Singleton classes. The syncronization method and instantiation methods can be changed easily by specifying different policy implementations as the templates parameters.

 // Most common Singleton
 Singletion<LonesomeType>

 // Singleton that uses static storage 
 Singletion<LonesomeType, StaticInstantiation>

 // Single-threaded singleton that uses static storage (Meyers-like)
 Singletion<LonesomeType, LocalStaticInstantiation, NotLocked>


Member Function Documentation

T* instance   [inline, static]
 

Provide access to the single instance through double-checked locking

Returns :
T* single instance


The documentation for this class was generated from the following file:
Generated on Tue Aug 27 07:43:14 2002 for ZThread by doxygen1.2.17