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

`#include <LockingPtr.h>`

List of all members.

## 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:

  | object | Reference to object.
  | mutex | Mutex 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:

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

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

- LockingPtr.h