process_mutex Class Reference
[Synchronisation Library]

#include <unixstl/synch/process_mutex.hpp>

Inheritance diagram for process_mutex:

critical_section< STLSOFT_CRITICAL_SECTION_ISNOT_RECURSIVE, STLSOFT_CRITICAL_SECTION_IS_TRYABLE > critical_section_tag

List of all members.


Detailed Description

This class provides an implementation of the mutex model based on the PTHREADS pthread_mutex_t.

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.

Constructor & Destructor Documentation

process_mutex (  )  [inline]

Creates an instance of the mutex.

Note:
This creates a recursive mutex. Use the other constructor(s) to obtain a non-recursive 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.

Parameters:
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.

Note:
On systems that support shared mutexes, this will be not shared. Use the two-parameter constructor to obtain a shared mutex

~process_mutex (  )  throw () [inline]

Destroys an instance of the mutex.


Member Function Documentation

void lock (  )  [inline]

Acquires a lock on the mutex, pending the thread until the lock is aquired.

Exceptions:
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.

Returns:
true if the mutex was aquired, or false if not.
Exceptions:
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.

Exceptions:
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.


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

Generated on Thu Jun 10 08:59:08 2010 for STLSoft by  doxygen 1.5.6