|
Loki
0.1.7
|
#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. | |
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.
| Loki::LockingPtr< SharedObject, LockingPolicy, ConstPolicy >::LockingPtr | ( | volatile ConstOrNotType & | object, |
| LockingPolicy & | mutex | ||
| ) | [inline] |
Constructor locks mutex associated with an object.
| object | Reference to object. |
| mutex | Mutex used to control thread access to object. |
| Loki::LockingPtr< SharedObject, LockingPolicy, ConstPolicy >::LockingPtr | ( | Pair | lockpair | ) | [inline] |
Constructor locks mutex associated with an object.
| lockpair | a std::pair of pointers to the object and the mutex |