MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | List of all members
Mezzanine::Threading::lock_guard< T > Class Template Reference

Lock guard class. More...

#include <lockguard.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

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

Detailed Description

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

Lock guard class.

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:

mutex m;
int counter;
void increment()
{
lock_guard<mutex> guard(m);
++counter;
}

Definition at line 91 of file lockguard.h.

Constructor & Destructor Documentation

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

The constructor locks the mutex.

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

Definition at line 99 of file lockguard.h.


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