Spinning Topp Logo BlackTopp Studios
Public Types | Public Member Functions | List of all members
Mezzanine::Threading::ReadOnlyLockGuard< T > Class Template Reference

Read only lock guard. More...

#include <readwritespinlock.h>

Public Types

typedef T mutex_type
 This allows other code to use the type of this mutex in a more safe way.

Public Member Functions

 ReadOnlyLockGuard (mutex_type &aMutex)
 The constructor locks the mutex. More...
 ~ReadOnlyLockGuard ()
 The destructor unlocks the mutex.

Detailed Description

template<class T>
class Mezzanine::Threading::ReadOnlyLockGuard< T >

Read only lock guard.

The constructor locks the mutex, and the destructor unlocks the mutex, so the mutex will automatically be unlocked when the lock guard goes out of scope. Example usage:

ReadWriteSpinLock m;
ClassThatIsWrittenInAnotherThread n;
ClassThatIsWrittenInAnotherThread GetCurrent()
ReadOnlyLockGuard<ReadWriteSpinLock> guard(m);
return n; // returns a copy guaranteed to be valid because
// the lock (which is attempted in the constructor
// of the guard) could not be acquired until only
// readers want it.

Definition at line 142 of file readwritespinlock.h.

Constructor & Destructor Documentation

template<class T >
Mezzanine::Threading::ReadOnlyLockGuard< T >::ReadOnlyLockGuard ( mutex_type aMutex)

The constructor locks the mutex.

aMutexAny mutex which implements lock() and unlock().

Definition at line 156 of file readwritespinlock.h.

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