Singleton< T, F, instance > Class Template Reference

Restricts the instantiation of a class to one static object without locks. More...

List of all members.

Public Member Functions

 Singleton (F objectFactory=F())
const T & Ref (...) const
 Return a reference to the inner Singleton object.

Detailed Description

template<class T, class F = NewObject<T>, int instance = 0>
class Singleton< T, F, instance >

Restricts the instantiation of a class to one static object without locks.

Template Parameters:
T the class or type
F the object factory for T
instance the initiali instance count

This class safely initializes a static object in a multithreaded environment without using locks (for portability). Note that if two threads call Ref() at the same time, they may get back different references, and one object may end up being memory leaked. This is by design.

Definition at line 236 of file misc.h.


Member Function Documentation

template<class T , class F , int instance>
const T & Singleton< T, F, instance >::Ref (   ...  )  const [inline]

Return a reference to the inner Singleton object.

Ref() is used to create the object using the object factory. The object is only created once with the limitations discussed in the class documentation.

Definition at line 252 of file misc.h.

References MEMORY_BARRIER.


The documentation for this class was generated from the following file:

Generated on 24 Mar 2016 for Crypto++ by  doxygen 1.6.1