cpp-pthread  (v1.7.3)
Simple C++ wrapper to pthread functions.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
Public Member Functions | Friends | List of all members
pthread::lock_guard< MutexType > Class Template Reference

#include <lock_guard.hpp>

Public Member Functions

 lock_guard (MutexType &m)
 
 ~lock_guard ()
 
MutexType * internal_mutex ()
 
void operator= (lock_guard &)=delete
 

Friends

class condition_variable
 

Detailed Description

template<class MutexType>
class pthread::lock_guard< MutexType >

This class was designed to encapsulate a mutex and automatically control the lock attribute.

The lock_guard lock the associated mutex once we instanciate the class and the lock is automatically unlocked once the object is destroyed. This allow us to correlate the lock with the scope of the object.

Author
herbert koelman
Examples:
synchronized_queue_tests.cpp.

Definition at line 38 of file lock_guard.hpp.

Constructor & Destructor Documentation

template<class MutexType>
pthread::lock_guard< MutexType >::lock_guard ( MutexType &  m)
inlineexplicit

The constructor is forced to only accept a mutex object or any object of a subclass.

The mutex is locked up upon completion.

Parameters
mreference to a valid pthread::mutex

Definition at line 50 of file lock_guard.hpp.

template<class MutexType>
pthread::lock_guard< MutexType >::~lock_guard ( )
inline

The destructor release the guarded mutex.

Definition at line 57 of file lock_guard.hpp.

Member Function Documentation

template<class MutexType>
MutexType* pthread::lock_guard< MutexType >::internal_mutex ( )
inline
Returns
a const reference to the guarded mutex
Deprecated:
condition_variable is now a friend class

Definition at line 65 of file lock_guard.hpp.

template<class MutexType>
void pthread::lock_guard< MutexType >::operator= ( lock_guard< MutexType > &  )
delete

Desabling the = operator.


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