chai3d::cMutex Class Reference

This class implements a mutex. More...

#include <CMutex.h>

Public Member Functions

 cMutex ()
 Constructor of cMutex. More...
 
virtual ~cMutex ()
 Destructor of cMutex. More...
 
bool acquire ()
 This method acquires the mutex. More...
 
bool tryAcquire ()
 This method acquires the mutex only if it is not owned by another thread. More...
 
void release ()
 This method releases the mutex. More...
 

Protected Attributes

CRITICAL_SECTION m_mutex
 Mutex handle. More...
 

Detailed Description

A mutex object is a synchronization object whose state is set to signaled when it is not owned by any thread, and non-signaled when it is owned. Only one thread at a time can own a mutex object, whose name comes from the fact that it is useful in coordinating mutually exclusive access to a shared resource. For example, to prevent two threads from writing to shared memory at the same time, each thread waits for ownership of a mutex object before executing the code that accesses the memory. After writing to the shared memory, the thread releases the mutex object.

Constructor & Destructor Documentation

chai3d::cMutex::cMutex ( )

Constructor of cMutex.

chai3d::cMutex::~cMutex ( )
virtual

Destructor of cMutex.

Member Function Documentation

bool chai3d::cMutex::acquire ( )

This method requests ownership of the mutex. The calling thread will wait until the mutex becomes available, or until a system timeout occurs (in which case the call is not successful).

Returns
true in case of success, false otherwise.
bool chai3d::cMutex::tryAcquire ( )

This method requests ownership of the mutex. The calling thread will return false immediately if the mutex is already owned by another thread. Otherwise, the calling thread is granted ownership of the mutex.

Returns
true in case of success, false otherwise.
void chai3d::cMutex::release ( )

This method makes the calling thread release ownership of the mutex.

Member Data Documentation

CRITICAL_SECTION chai3d::cMutex::m_mutex
protected

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