nidas v1.2.3
Public Member Functions | Private Member Functions | Private Attributes | List of all members
nidas::util::RWLock Class Reference

A C++ wrapper for a POSIX rwlock. More...

#include <ThreadSupport.h>

Public Member Functions

 RWLock () throw ()
 Construct a POSIX rwlock.
 
 RWLock (const RWLockAttributes &attr)
 
 RWLock (const RWLock &x) throw ()
 Copy constructor.
 
 ~RWLock ()
 Destruct a RWLock.
 
void rdlock ()
 Acquire a read lock.
 
void wrlock ()
 Acquire a write lock.
 
void unlock ()
 Unlock the RWLock.
 
pthread_rwlock_t * ptr ()
 Get the pointer to the pthread_rwlock_t.
 

Private Member Functions

RWLockoperator= (const RWLock &)
 No assignment allowed.
 

Private Attributes

pthread_rwlock_t _p_rwlock
 
RWLockAttributes _attrs
 

Detailed Description

A C++ wrapper for a POSIX rwlock.

Constructor & Destructor Documentation

◆ RWLock() [1/3]

RWLock::RWLock ( )
throw ( )

Construct a POSIX rwlock.

See man page for pthread_rwlock_init.

References _attrs, _p_rwlock, and nidas::util::RWLockAttributes::ptr().

◆ RWLock() [2/3]

RWLock::RWLock ( const RWLockAttributes & attr)

◆ RWLock() [3/3]

RWLock::RWLock ( const RWLock & x)
throw ( )

Copy constructor.

Creates a new, unlocked rwlock.

◆ ~RWLock()

RWLock::~RWLock ( )

Destruct a RWLock.

See man page for pthread_rwlock_destroy. RwLock must not be locked, otherwise std::terminate() is called.

References _p_rwlock, and CLOG.

Member Function Documentation

◆ operator=()

RWLock & nidas::util::RWLock::operator= ( const RWLock & )
private

No assignment allowed.

◆ ptr()

pthread_rwlock_t * RWLock::ptr ( )

Get the pointer to the pthread_rwlock_t.

References _p_rwlock.

◆ rdlock()

void nidas::util::RWLock::rdlock ( )
inline

Acquire a read lock.

May throw an exception if the maximum number of read locks for this RWLock has been exceeded.

Exceptions
Exception

References _p_rwlock.

Referenced by nidas::util::AutoRdLock::AutoRdLock(), and nidas::dynld::UDPSampleOutput::getProjectDOM().

◆ unlock()

void nidas::util::RWLock::unlock ( )
inline

Unlock the RWLock.

Will throw an exception EPERM if the current thread does not hold a lock.

Exceptions
Exception

References _p_rwlock.

Referenced by nidas::dynld::UDPSampleOutput::releaseProjectDOM(), nidas::util::AutoRdLock::~AutoRdLock(), and nidas::util::AutoWrLock::~AutoWrLock().

◆ wrlock()

void nidas::util::RWLock::wrlock ( )
inline

Acquire a write lock.

May throw an exception if the current thread already owns the lock.

Exceptions
Exception

References _p_rwlock.

Referenced by nidas::util::AutoWrLock::AutoWrLock().

Member Data Documentation

◆ _attrs

RWLockAttributes nidas::util::RWLock::_attrs
private

Referenced by RWLock(), and RWLock().

◆ _p_rwlock

pthread_rwlock_t nidas::util::RWLock::_p_rwlock
private

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