EPICS Base  7.0.8.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Types | Public Member Functions | Friends | List of all members
epicsGuard< T > Class Template Reference

Provides an RAII style lock/unlock of a mutex. More...

#include <epicsGuard.h>

Public Types

typedef epicsGuardRelease< T > release_t
 

Public Member Functions

 epicsGuard (T &mutexIn)
 Guard a mutex based on scope. More...
 
void assertIdenticalMutex (const T &) const
 

Friends

class epicsGuardRelease< T >
 

Detailed Description

template<class T>
class epicsGuard< T >

Provides an RAII style lock/unlock of a mutex. When this object is created, it attempts to lock the mutex it was given. When control leaves the scope where this was created, the destructor unlocks the mutex.

This class is also useful in situations where C++ exceptions are possible.

Example

epicsMutex mutex;
{
epicsGuard guard(mutex);
printf("mutex is locked")
}
printf("mutex is unlocked\n");

Definition at line 53 of file epicsGuard.h.

Constructor & Destructor Documentation

template<class T>
epicsGuard< T >::epicsGuard ( T &  mutexIn)
inline

Constructs an epicsGuard, locking the mutex for the scope of this object.

Parameters
mutexInA mutex-like object to be lock()'ed and unlock()'ed

Definition at line 140 of file epicsGuard.h.


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