#include <Mutex.h>
Inheritance diagram for ZThread::Mutex:
Public Member Functions | |
Mutex () | |
Create a new Mutex. | |
virtual | ~Mutex () |
Destroy this Mutex. | |
virtual void | acquire () |
virtual bool | tryAcquire (unsigned long timeout) |
virtual void | release () |
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.
void ZThread::Mutex::acquire | ( | ) | [virtual] |
Acquire a Mutex, possibly blocking until either the current owner of the Mutex releases it or until an exception is thrown.
Only one thread may acquire() the Mutex at any given time.
Interrupted_Exception | thrown when the calling thread is interrupted. A thread may be interrupted at any time, prematurely ending any wait. | |
Deadlock_Exception | thrown when the same thread attempts to acquire a Mutex more than once, without having first release()ed it. |
Implements ZThread::Lockable.
void ZThread::Mutex::release | ( | ) | [virtual] |
Release a Mutex allowing another thread to acquire it.
InvalidOp_Exception | - thrown if there is an attempt to release is a Mutex that was not owner by the calling thread. |
Implements ZThread::Lockable.
bool ZThread::Mutex::tryAcquire | ( | unsigned long | timeout | ) | [virtual] |
Acquire a Mutex, possibly blocking until the current owner of the Mutex releases 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.
timeout | maximum amount of time (milliseconds) this method could block |
Interrupted_Exception | thrown when the calling thread is interrupted. A thread may be interrupted at any time, prematurely ending any wait. | |
Deadlock_Exception | thrown when the same thread attempts to acquire a Mutex more than once, without having first released it. |
Implements ZThread::Lockable.