CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

csMutex Class Reference

A mutual-exclusion object. More...

#include <thread.h>

Inheritance diagram for csMutex:

csRefCount List of all members.

Public Methods

virtual bool LockWait ()=0
 Lock the mutex.

virtual bool LockTry ()=0
 Lock the mutex if not already locked by some other entity.

virtual bool Release ()=0
 Unlock the mutex.

virtual char const * GetLastError ()=0
 Return the last error description, else 0 if there was none.


Static Public Methods

csRef< csMutex > Create (bool needrecursive=false)
 Create a mutex.


Detailed Description

A mutual-exclusion object.

A thread-safe lock. Mutexes are often used to control access to one or more resources shared by multiple threads of execution. A thread should access the shared resource(s) only after it has successfully locked the mutex; and it should unlock the mutex when it is done accessing the shared resource so that other threads may access it.

Definition at line 126 of file thread.h.


Member Function Documentation

csRef<csMutex> csMutex::Create bool    needrecursive = false [static]
 

Create a mutex.

Note that the mutexes on Windows are always recursive (ie. the same thread is able to Lock the mutex multiple times), while on other platforms non recursive threads may be the default since they are can be implemented more efficiently. If you need recursive behaviour set needrecursive to true. Note: It seems that "conditionals" on Linux only work with non-recursive mutexes.

virtual char const* csMutex::GetLastError   [pure virtual]
 

Return the last error description, else 0 if there was none.

virtual bool csMutex::LockTry   [pure virtual]
 

Lock the mutex if not already locked by some other entity.

Does not suspend the thread waiting for the lock. If lock succeeded, returns true. If lock failed, immediately returns false. Each successful call to LockTry() must be balanced with a call to Release().

virtual bool csMutex::LockWait   [pure virtual]
 

Lock the mutex.

Suspends execution of the thread until the mutex can be locked. Each LockWait() must be balanced by a call to Release(). Returns true if locking succeeded. Returns false if locking failed for some catastrophic reason; check GetLastError().

virtual bool csMutex::Release   [pure virtual]
 

Unlock the mutex.

Each successful call to LockWait() or LockTry() must be balanced by a call to Release(). Returns true if unlocking succeeded. Returns false if unlocking failed for some catastrophic reason; check GetLastError().


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.2.18