Loki  0.1.7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Groups
Loki::LockingPtr< SharedObject, LockingPolicy, ConstPolicy > Class Template Reference

#include <LockingPtr.h>

Public Member Functions

 LockingPtr (volatile ConstOrNotType &object, LockingPolicy &mutex)
 
 LockingPtr (Pair lockpair)
 
 ~LockingPtr ()
 Destructor unlocks the mutex.
 
ConstOrNotType & operator* ()
 Star-operator dereferences pointer.
 
ConstOrNotType * operator-> ()
 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.

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
objectReference to object.
mutexMutex used to control thread access to object.
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
lockpaira std::pair of pointers to the object and the mutex

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