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

A C++ wrapper for a POSIX mutex attributes. More...

#include <ThreadSupport.h>

Public Member Functions

 MutexAttributes ()
 Create instance with default values, type = PTHREAD_MUTEX_DEFAULT, priority protocol=PTHREAD_PRIO_NONE and pshared = PTHREAD_PROCESS_PRIVATE.
 
 MutexAttributes (const MutexAttributes &)
 Copy constructor.
 
 ~MutexAttributes ()
 
void setType (int val)
 Set the mutex type attribute, one of PTHREAD_MUTEX_NORMAL,PTHREAD_MUTEX_ERRORCHECK,PTHREAD_MUTEX_RECURSIVE, or PTHREAD_MUTEX_DEFAULT.
 
int getType () const
 
void setPShared (int val)
 Set the mutex pshared attribute, one of PTHREAD_PROCESS_PRIVATE or PTHREAD_PROCESS_SHARED.
 
int getPShared () const
 
pthread_mutexattr_t * ptr ()
 

Private Attributes

pthread_mutexattr_t _attrs
 

Detailed Description

A C++ wrapper for a POSIX mutex attributes.

These are customizations for Mutexes, and are only needed if you want more than the default error checking, if you want recursive behaviour where a thread can hold more than lock on the same mutex, if you are using fine-grained thread scheduling priority, or want to share a Mutex between processes.

See man pages for pthread_mutexattr_init, pthread_mutexattr_settype, pthread_mutexattr_setprioceiling, pthread_mutexattr_setprotocol, and pthread_mutexattr_setpshared.

Constructor & Destructor Documentation

◆ MutexAttributes() [1/2]

MutexAttributes::MutexAttributes ( )

Create instance with default values, type = PTHREAD_MUTEX_DEFAULT, priority protocol=PTHREAD_PRIO_NONE and pshared = PTHREAD_PROCESS_PRIVATE.

References _attrs.

◆ MutexAttributes() [2/2]

MutexAttributes::MutexAttributes ( const MutexAttributes & x)

Copy constructor.

References _attrs, setPShared(), and setType().

◆ ~MutexAttributes()

MutexAttributes::~MutexAttributes ( )

References _attrs.

Member Function Documentation

◆ getPShared()

int MutexAttributes::getPShared ( ) const

References _attrs.

◆ getType()

int MutexAttributes::getType ( ) const

References _attrs.

◆ ptr()

pthread_mutexattr_t * nidas::util::MutexAttributes::ptr ( )
inline

References _attrs.

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

◆ setPShared()

void MutexAttributes::setPShared ( int val)

Set the mutex pshared attribute, one of PTHREAD_PROCESS_PRIVATE or PTHREAD_PROCESS_SHARED.

See pthread_mutexattr_setpshared.

Exceptions
Exception

References _attrs.

Referenced by MutexAttributes().

◆ setType()

void MutexAttributes::setType ( int val)

Set the mutex type attribute, one of PTHREAD_MUTEX_NORMAL,PTHREAD_MUTEX_ERRORCHECK,PTHREAD_MUTEX_RECURSIVE, or PTHREAD_MUTEX_DEFAULT.

See pthread_mutexattr_settype.

Exceptions
Exception

References _attrs.

Referenced by MutexAttributes().

Member Data Documentation

◆ _attrs

pthread_mutexattr_t nidas::util::MutexAttributes::_attrs
private

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