#include <unixstl/synch/spin_mutex.hpp>
Member Types | |
typedef spin_mutex_base< SP > | class_type |
This class. | |
typedef us_sint32_t | count_type |
The count type. | |
typedef bool | bool_type |
The bool type. | |
typedef | unixstl_ns_qual (atomic_int_t) atomic_int_type |
The atomic integer type. | |
Public Member Functions | |
Construction | |
spin_mutex_base (atomic_int_type *p=NULL) throw () | |
Creates an instance of the mutex. | |
spin_mutex_base (atomic_int_type *p, bool_type bYieldOnSpin) throw () | |
Creates an instance of the mutex. | |
~spin_mutex_base () throw () | |
Destroys an instance of the mutex. | |
Operations | |
void | lock () throw () |
Acquires a lock on the mutex, pending the thread until the lock is aquired. | |
void | unlock () throw () |
Releases an aquired lock on the mutex. | |
Attributes | |
count_type | spun_count () const |
An indicator as to the level of contention on the mutex. |
typedef spin_mutex_base<SP> class_type |
This class.
typedef us_sint32_t count_type |
The count type.
typedef bool bool_type |
The bool type.
spin_mutex_base | ( | atomic_int_type * | p = NULL |
) | throw () [inline, explicit] |
Creates an instance of the mutex.
p | Pointer to an external counter variable. May be NULL, in which case an internal member is used for the counter variable. |
spin_mutex_base | ( | atomic_int_type * | p, | |
bool_type | bYieldOnSpin | |||
) | throw () [inline] |
Creates an instance of the mutex.
p | Pointer to an external counter variable. May be NULL, in which case an internal member is used for the counter variable. | |
bYieldOnSpin |
~spin_mutex_base | ( | ) | throw () [inline] |
typedef unixstl_ns_qual | ( | atomic_int_t | ) |
The atomic integer type.
void lock | ( | ) | throw () [inline] |
Acquires a lock on the mutex, pending the thread until the lock is aquired.
References UNIXSTL_ASSERT, UNIXSTL_HAS_ATOMIC_WRITE, and UNIXSTL_MESSAGE_ASSERT.
void unlock | ( | ) | throw () [inline] |
count_type spun_count | ( | ) | const [inline] |
An indicator as to the level of contention on the mutex.
The value returned is only reliable when an external counter variable is being used, and when each spin_mutex instance is thread-specific. In all other cases, the spun count is subject to race conditions (that do not affect the good functioning of the spin_mutex) and value returned may be, at best, used only as a guide as to contention.