EPICS ARCHIVER V4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
Public Member Functions | Static Public Attributes | List of all members
OrderedMutex Class Reference

A mutex with informational name and lock order. More...

#include <OrderedMutex.h>

Public Member Functions

 OrderedMutex (const char *name, size_t order)
 Create mutex with name and lock order. More...
 
 ~OrderedMutex ()
 Destructor. More...
 
const stdString & getName () const
 
size_t getOrder () const
 
void lock (const char *file, size_t line)
 Lock the mutex. More...
 
void unlock ()
 Unlock the mutex. More...
 

Static Public Attributes

static const size_t Throttle = 101
 Lock order used by Tools::Throttle. More...
 
static const size_t ConcurrentList = 100
 Lock order used by Tools::ConcurrentList. More...
 

Detailed Description

A mutex with informational name and lock order.

Meant to help with deadlock-detection based on a predetermined lock order. For example, if an application defines locks with order

, then one has to take them individually or in the order a, b, c.

Attempts to take these mutexes out of order, which could result in deadlocks, are detected. For example, locking b, a or c, a will result in a printout of all threads and the locks which they currently hold, followed by an exception.

Constructor & Destructor Documentation

OrderedMutex::OrderedMutex ( const char *  name,
size_t  order 
)

Create mutex with name and lock order.

OrderedMutex::~OrderedMutex ( )

Destructor.

Member Function Documentation

const stdString& OrderedMutex::getName ( ) const
inline
Returns
Returns the mutex name.
size_t OrderedMutex::getOrder ( ) const
inline
Returns
Returns the mutex order.
void OrderedMutex::lock ( const char *  file,
size_t  line 
)

Lock the mutex.

Attempts to lock this mutex while higher-order mutexes are already taken will result in an exception.

Parameters file and line will be used in error messages.

void OrderedMutex::unlock ( )

Unlock the mutex.

Member Data Documentation

const size_t OrderedMutex::ConcurrentList = 100
static

Lock order used by Tools::ConcurrentList.

const size_t OrderedMutex::Throttle = 101
static

Lock order used by Tools::Throttle.


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