LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
LSSTDataManagementBasePackage
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
lsst::ap::SharedMutex Class Reference

A wrapper for a POSIX process shared mutual exclusion lock. More...

#include <Mutex.h>

Inheritance diagram for lsst::ap::SharedMutex:

Public Member Functions

 SharedMutex ()
 
 ~SharedMutex ()
 

Private Member Functions

void acquire ()
 
bool tryAcquire ()
 
void release ()
 

Private Attributes

::pthread_mutex_t _mutex
 

Friends

class ScopedLock< SharedMutex >
 
class Condition< SharedMutex >
 

Detailed Description

A wrapper for a POSIX process shared mutual exclusion lock.

Definition at line 97 of file Mutex.h.

Constructor & Destructor Documentation

lsst::ap::SharedMutex::SharedMutex ( )

Definition at line 46 of file Mutex.cc.

46  {
47  ::pthread_mutexattr_t attr;
48 
49  int err = ::pthread_mutexattr_init(&attr);
50  if (err != 0) {
51  throw LSST_EXCEPT(ex::RuntimeError,
52  (boost::format("pthread_mutexattr_init() failed, return code: %1%") % err).str());
53  }
54  ScopeGuard attrGuard(boost::bind(::pthread_mutexattr_destroy, &attr));
55  ::pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
56  err = ::pthread_mutex_init(&_mutex, &attr);
57  if (err != 0) {
58  throw LSST_EXCEPT(ex::RuntimeError,
59  (boost::format("pthread_mutex_init() failed, return code: %1%") % err).str());
60  }
61 }
::pthread_mutex_t _mutex
Definition: Mutex.h:110
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
lsst::ap::SharedMutex::~SharedMutex ( )
inline

Definition at line 103 of file Mutex.h.

103  {
104  int result = ::pthread_mutex_destroy(&_mutex);
105  assert(result == 0);
106  }
::pthread_mutex_t _mutex
Definition: Mutex.h:110

Member Function Documentation

void lsst::ap::SharedMutex::acquire ( )
inlineprivate

Definition at line 112 of file Mutex.h.

112  {
113  int result = ::pthread_mutex_lock(&_mutex);
114  assert(result == 0);
115  }
::pthread_mutex_t _mutex
Definition: Mutex.h:110
void lsst::ap::SharedMutex::release ( )
inlineprivate

Definition at line 121 of file Mutex.h.

121  {
122  int result = ::pthread_mutex_unlock(&_mutex);
123  assert(result == 0);
124  }
::pthread_mutex_t _mutex
Definition: Mutex.h:110
bool lsst::ap::SharedMutex::tryAcquire ( )
inlineprivate

Definition at line 117 of file Mutex.h.

117  {
118  return ::pthread_mutex_trylock(&_mutex) == 0;
119  }
::pthread_mutex_t _mutex
Definition: Mutex.h:110

Friends And Related Function Documentation

friend class Condition< SharedMutex >
friend

Definition at line 127 of file Mutex.h.

friend class ScopedLock< SharedMutex >
friend

Definition at line 126 of file Mutex.h.

Member Data Documentation

::pthread_mutex_t lsst::ap::SharedMutex::_mutex
private

Definition at line 110 of file Mutex.h.


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