spin_mutex_base Class Template Reference
[Synchronisation Library]

#include <unixstl/synch/spin_mutex.hpp>

Inheritance diagram for spin_mutex_base:

critical_section< STLSOFT_CRITICAL_SECTION_ISNOT_RECURSIVE, STLSOFT_CRITICAL_SECTION_ISNOT_TRYABLE > critical_section_tag

List of all members.


Detailed Description

template<typename SP>
class unixstl::spin_mutex_base< SP >

This class provides an implementation of the mutex model based on a spinning mechanism.

Note:
A spin mutex is not recursive. If you re-enter it your thread will be in irrecoverable deadlock.

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.

Member Typedef Documentation

This class.

typedef us_sint32_t count_type

The count type.

typedef bool bool_type

The bool type.


Constructor & Destructor Documentation

spin_mutex_base ( atomic_int_type *  p = NULL  )  throw () [inline, explicit]

Creates an instance of the mutex.

Parameters:
p Pointer to an external counter variable. May be NULL, in which case an internal member is used for the counter variable.
Note:

spin_mutex_base ( atomic_int_type *  p,
bool_type  bYieldOnSpin 
) throw () [inline]

Creates an instance of the mutex.

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

Destroys an instance of the mutex.

References UNIXSTL_ASSERT.


Member Function Documentation

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]

Releases an aquired lock on the mutex.

References UNIXSTL_ASSERT.

count_type spun_count (  )  const [inline]

An indicator as to the level of contention on the mutex.

Note:
The value returned is only meaningful after lock() has been called and before a corresponding unlock() has been called.

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.


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

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