Discrete Dipole Approximation Project  1.0
Plugin based Discrete Dipole Approximation (DDA) software package.
Thread::Mutex Class Reference

Detailed Description

Mutex object, provides basic thread synchronization a Mutex and by held by a single thread at a time the mutex is aquired by calling Lock or TryLock and released by calling Unlock.

#include "thread.h"

Public Member Functions

 Mutex (bool Lock=false)
 Constructs a new Mutex Object, it Lock is true the new Mutex Object is held by the current thread.
 
 ~Mutex ()
 Destroys the Mutex Object.
 
bool Lock (unsigned long timeout, bool execpt=true)
 Aquires the Mutex object when the Mutex is unlocked. More...
 
bool TryLock ()
 Atempts to aquire the Mutex and returns immediately. More...
 
bool Unlock ()
 Release the Mutex. More...
 

Member Function Documentation

bool Thread::Mutex::Lock ( unsigned long  timeout,
bool  execpt = true 
)
inline

If the Mutex is locked, this call will block until the Mutex is unlocked of timeout has been exceeded.

Returns
true if aquired, false otherwise.
Exceptions
TimeoutExceptionRaised in execpt is true and timeout has been exceeded.
bool Thread::Mutex::TryLock ( )
inline

This function will fail if the Mutex is locked.

Returns
true if aquired, false otherwise.
bool Thread::Mutex::Unlock ( )
inline
Returns
true on success, false on error.