Loki::LockingPtr< SharedObject, LockingPolicy, ConstPolicy > Class Template Reference

#include <LockingPtr.h>

List of all members.

Public Types

typedef ConstPolicy< SharedObject
>::Type 
ConstOrNotType
typedef std::pair< volatile
ConstOrNotType *, LockingPolicy * > 
Pair

Public Member Functions

 LockingPtr (volatile ConstOrNotType &object, LockingPolicy &mutex)
 LockingPtr (Pair lockpair)
 ~LockingPtr ()
 Destructor unlocks the mutex.
ConstOrNotTypeoperator * ()
 Star-operator dereferences pointer.
ConstOrNotTypeoperator-> ()
 Point-operator returns pointer to object.


Detailed Description

template<typename SharedObject, typename LockingPolicy = LOKI_DEFAULT_MUTEX, template< class > class ConstPolicy = LOKI_DEFAULT_CONSTNESS>
class Loki::LockingPtr< SharedObject, LockingPolicy, ConstPolicy >

Locks a volatile object and casts away volatility so that the object can be safely used in a single-threaded region of code. Original version of LockingPtr had only one template - for the shared object, but not the mutex type. This version allows users to specify a the mutex type as a LockingPolicy class. The only requirements for a LockingPolicy class are to provide Lock and Unlock methods.

Definition at line 32 of file LockingPtr.h.


Constructor & Destructor Documentation

template<typename SharedObject, typename LockingPolicy = LOKI_DEFAULT_MUTEX, template< class > class ConstPolicy = LOKI_DEFAULT_CONSTNESS>
Loki::LockingPtr< SharedObject, LockingPolicy, ConstPolicy >::LockingPtr ( volatile ConstOrNotType object,
LockingPolicy &  mutex 
) [inline]

Constructor locks mutex associated with an object.

Parameters:
object Reference to object.
mutex Mutex used to control thread access to object.

Definition at line 42 of file LockingPtr.h.

template<typename SharedObject, typename LockingPolicy = LOKI_DEFAULT_MUTEX, template< class > class ConstPolicy = LOKI_DEFAULT_CONSTNESS>
Loki::LockingPtr< SharedObject, LockingPolicy, ConstPolicy >::LockingPtr ( Pair  lockpair  )  [inline]

Constructor locks mutex associated with an object.

Parameters:
lockpair a std::pair of pointers to the object and the mutex

Definition at line 54 of file LockingPtr.h.


The documentation for this class was generated from the following file:
Generated on Sun Feb 25 16:52:44 2007 for Loki by  doxygen 1.5.1-p1