#include <unixstl/synch/process_mutex.hpp>
Public Types | |
Member Types | |
typedef process_mutex | class_type |
typedef bool | bool_type |
typedef pthread_mutex_t * | resource_type |
Public Member Functions | |
Construction | |
process_mutex () | |
Creates an instance of the mutex. | |
process_mutex (pthread_mutex_t *mx, bool_type bTakeOwnership) | |
Conversion constructor. | |
process_mutex (bool_type bRecursive) | |
Creates an instance of the mutex. | |
~process_mutex () throw () | |
Destroys an instance of the mutex. | |
Operations | |
void | lock () |
Acquires a lock on the mutex, pending the thread until the lock is aquired. | |
bool | try_lock () |
Attempts to lock the mutex. | |
void | unlock () |
Releases an aquired lock on the mutex. | |
int | get_error () const throw () |
Contains the last failed error code from the underlying PTHREADS API. | |
Accessors | |
pthread_mutex_t * | handle () throw () |
The underlying kernel object handle. | |
pthread_mutex_t * | get () throw () |
The underlying kernel object handle. |
process_mutex | ( | ) | [inline] |
Creates an instance of the mutex.
On systems that support shared mutexes, this will be not shared. Use the other constructor to obtain a shared mutex
process_mutex | ( | pthread_mutex_t * | mx, | |
bool_type | bTakeOwnership | |||
) | [inline] |
Conversion constructor.
mx | The raw mutex object handle that this instance will use | |
bTakeOwnership | If true, the handle is closed when this instance is destroyed |
References UNIXSTL_ASSERT.
process_mutex | ( | bool_type | bRecursive | ) | [inline, explicit] |
Creates an instance of the mutex.
~process_mutex | ( | ) | throw () [inline] |
Destroys an instance of the mutex.
void lock | ( | ) | [inline] |
Acquires a lock on the mutex, pending the thread until the lock is aquired.
unixstl::synchronisation_exception | When compiling with exception support, this will throw unixstl::synchronisation_exception if the lock cannot be acquired. When compiling absent exception support, failure to acquire the lock will be reflected in a non-zero return from get_error(). |
bool try_lock | ( | ) | [inline] |
Attempts to lock the mutex.
unixstl::synchronisation_exception | When compiling with exception support, this will throw unixstl::synchronisation_exception if the lock cannot be acquired for a reason other than a timeout (EBUSY ). When compiling absent exception support, failure to acquire the lock (for any other reason) will be reflected in a non-zero return from get_error(). |
void unlock | ( | ) | [inline] |
Releases an aquired lock on the mutex.
unixstl::synchronisation_exception | When compiling with exception support, this will throw unixstl::synchronisation_exception if the lock cannot be released. When compiling absent exception support, failure to release the lock will be reflected in a non-zero return from get_error(). |
int get_error | ( | ) | const throw () [inline] |
Contains the last failed error code from the underlying PTHREADS API.
pthread_mutex_t* handle | ( | ) | throw () [inline] |
The underlying kernel object handle.
pthread_mutex_t* get | ( | ) | throw () [inline] |
The underlying kernel object handle.