News SF.net Project Frequently Asked Questions Documentation Downloads Mailing Lists How to Contribute

SourceForge.net Logo

Changing the way games are made and played.

TNL::Mutex class Reference

TNL::Mutex Class Reference

#include <tnlThread.h>


Detailed Description

Platform independent Mutual Exclusion implementation.


Public Member Functions

 Mutex ()
 Mutex constructor.

 ~Mutex ()
 Mutex destructor.

void lock ()
 Locks the Mutex.

void unlock ()
 Unlocks the Mutex.

bool tryLock ()
 Attempts to acquire a lock to this Mutex, without blocking.


Private Attributes

pthread_mutex_t mMutex


Constructor & Destructor Documentation

TNL::Mutex::Mutex  ) 
 

Mutex constructor.

TNL::Mutex::~Mutex  ) 
 

Mutex destructor.


Member Function Documentation

void TNL::Mutex::lock  ) 
 

Locks the Mutex.

If another thread already has this Mutex locked, this call will block until it is unlocked. If the lock method is called from a thread that has already locked this Mutex, the call will not block and the thread will have to unlock the mutex for as many calls as were made to lock before another thread will be allowed to lock the Mutex.

void TNL::Mutex::unlock  ) 
 

Unlocks the Mutex.

The behavior of this method is undefined if called by a thread that has not previously locked this Mutex.

bool TNL::Mutex::tryLock  ) 
 

Attempts to acquire a lock to this Mutex, without blocking.

Returns true if the calling thread was able to lock the Mutex and false if the Mutex was already locked by another thread.


Field Documentation

pthread_mutex_t TNL::Mutex::mMutex [private]