Template Class epicsGuard

Class Documentation

template<class T>
class epicsGuard

Provides an RAII style lock/unlock of a mutex.

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");

Public Types

typedef epicsGuardRelease<T> release_t

Public Functions

inline epicsGuard(T &mutexIn)

Guard a mutex based on scope.

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

Parameters

mutexIn – A mutex-like object to be lock()’ed and unlock()’ed

inline void assertIdenticalMutex(const T&) const
inline ~epicsGuard()