Public Member Functions | Static Public Attributes | Friends

System::Mutex Class Reference

Mutex - provides synchronization, the ability to control how threads share resources. More...

#include <B2BITS_Mutex.h>

Collaboration diagram for System::Mutex:

List of all members.

Public Member Functions

void lock ()
 Locks the mutex.
 Mutex (std::string const &debugName=std::string())
 Constructor.
bool tryLock ()
void unlock ()
 Unlocks the mutex.
virtual ~Mutex ()
 Destructor.

Static Public Attributes

static pthread_mutexattr_t s_mutexAttr
 Describes the attributes of a thread mutex.

Friends

class Condition
void onceMutexRoutine ()
class Utils::CTGuard< Mutex >

Detailed Description

Mutex - provides synchronization, the ability to control how threads share resources.

You use mutexes to prevent multiple threads from modifying shared data at the same time, and to ensure that a thread can read consistent values for a set of resources (for example, memory) that may be modified by other threads.

Definition at line 80 of file B2BITS_Mutex.h.


Constructor & Destructor Documentation

System::Mutex::Mutex ( std::string const &  debugName = std::string() ) [explicit]

Constructor.

virtual System::Mutex::~Mutex (  ) [virtual]

Destructor.


Member Function Documentation

void System::Mutex::lock (  )

Locks the mutex.

If the mutex is currently locked, the calling thread is blocked until mutex is unlocked. On return, the thread owns the mutex until it calls Mutex::unlock().

Referenced by System::LockingPtr< T >::LockingPtr().

bool System::Mutex::tryLock (  )
void System::Mutex::unlock (  )

Unlocks the mutex.

The mutex becomes unowned. If any threads are waiting for the mutex, one is awakened.

Referenced by System::LockingPtr< T >::~LockingPtr().


Friends And Related Function Documentation

friend class Condition [friend]

Definition at line 83 of file B2BITS_Mutex.h.

void onceMutexRoutine (  ) [friend]
friend class Utils::CTGuard< Mutex > [friend]

Definition at line 87 of file B2BITS_Mutex.h.


Member Data Documentation

pthread_mutexattr_t System::Mutex::s_mutexAttr [static]

Describes the attributes of a thread mutex.

It should be considered an opaque record, the names of the fields can change anytime.

Definition at line 113 of file B2BITS_Mutex.h.