Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

vuMutex Class Reference

Wrapper class for POSIX mutex. More...

#include <vuThread.h>

Collaboration diagram for vuMutex:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 vuMutex ()
 Default constructor.
 ~vuMutex ()
 Destructor.
void lock ()
 Locks the mutex.
bool trylock ()
 Try to lock the mutex.
void unlock ()
 Unlock the mutex.

Private Attributes

void * mutex

Friends

class vuLock

Detailed Description

Wrapper class for POSIX mutex.

A mutex can be locked and unlocked. If a locked mutex is tried to be locked againg (e.g. by a parallel running thread) the thread is blocked until the mutex is free again. This can be used to manage access to shared resources or synchronize between different threads.

Definition at line 48 of file vuThread.h.


Constructor & Destructor Documentation

vuMutex::vuMutex  ) 
 

Default constructor.

Calls pthread_mutex_init()

Definition at line 111 of file vuThread.cpp.

References mutex, and NULL.

vuMutex::~vuMutex  ) 
 

Destructor.

Calls pthread_mutex_destroy()

Definition at line 117 of file vuThread.cpp.

References mutex.


Member Function Documentation

void vuMutex::lock  ) 
 

Locks the mutex.

If the mutex has already been locked by another process this function waits until the mutex is free. This is the recommended method to synchronize between threads. While waiting for the mutex to get free no cpu time is waisted.

Definition at line 123 of file vuThread.cpp.

References mutex.

Referenced by vu1112117::computeSlicesUsingThreads(), vu1512112::drawSlices(), vu1112117::refineSlicesUsingThreads(), ns_vu1112112::vu1112112::render(), vu1112113::render(), and vuThread::startThread().

bool vuMutex::trylock  ) 
 

Try to lock the mutex.

Same as lock() but if mutex is busy the calling thread is not blocked.

Returns:
true if mutex was successfully locked. false if mutex busy.

Definition at line 128 of file vuThread.cpp.

References mutex.

void vuMutex::unlock  ) 
 

Unlock the mutex.

Allow other threads to lock the mutex. If you forget this the program will get stuck...

Definition at line 133 of file vuThread.cpp.

References mutex.

Referenced by _kickoff(), vu1112117::computeSlicesUsingThreads(), vu1512112::drawSlices(), vu1112117::refineSlicesUsingThreads(), ns_vu1112112::vu1112112::render(), vu1112113::render(), ns_vu1112112::vu1112112::run(), vu1112113::run(), and vu1112117::run().


Friends And Related Function Documentation

friend class vuLock [friend]
 

Definition at line 50 of file vuThread.h.


Member Data Documentation

void* vuMutex::mutex [private]
 

Definition at line 74 of file vuThread.h.

Referenced by lock(), trylock(), unlock(), vuMutex(), and ~vuMutex().


The documentation for this class was generated from the following files:
Generated on Wed Dec 15 21:22:00 2004 for vuVolume by  doxygen 1.3.9.1