LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
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: