#include <Mutex.h>
Inheritance diagram for Mutex:
Public Methods | |
Mutex () | |
Create a new Mutex. | |
virtual | ~Mutex () throw () |
Destroy this Mutex. | |
virtual void | acquire () |
virtual bool | tryAcquire (unsigned long) |
virtual void | release () |
Using a Mutex requires special care. It is often easy to forget to release() a Mutex after having acquire()ed it. Especially in situations where the flow of execution is not linear because of branching and/or exception. The Guard class is an application of the Scoped Locking pattern which helps to remove this difficulty from multi-threaded code.
Threads competing to acquire() a Mutex are granted access in FIFO order.
Error Checking
A Mutex will throw a Deadlock_Exception if an attempt to acquire() a Mutex more than once is made from the context of the same thread.
A Mutex will throw an InvalidOp_Exception if an attempt to release() a Mutex is made from the context of a thread that does not currently own that Mutex.
|
Acquire a Mutex, possbily blocking until the the current owner of the Mutex release()es it or until an exception is thrown. Only one thread may acquire() the Mutex at any given time.
Implements Lockable. |
|
Release a Mutex allowing another thread to acquire() it. see Lockable::release()
Implements Lockable. |
|
Acquire a Mutex, possbily blocking until the the current owner of the Mutex release()es it, until an exception is thrown or until the given amount of time expires. Only one thread may acquire() the Mutex at any given time.
Implements Lockable. |