Inheritance diagram for MCMonitor:
Public Member Functions
|virtual void||lock ()|
|Lock the mutex associated with the monitor. |
|Construct a monitor. |
|virtual void||notify ()|
|Notify a single waiter. |
|virtual void||notifyAll ()|
|Notify all waiters. |
|virtual void||unlock ()|
|Decrements the entry count associated with the monitor by one. |
|virtual bool||wait (mcinterval_t interval)|
|Wait for the monitor. |
|virtual void||wait ()|
|Wait indefinitely for the monitor. |
|Destruct the monitor. |
As with condition variables, the monitor uses a mutex but in this case, it is an integral part of the monitor object. Calling lock() on the monitor causes the mutex to be locked unless it is already locked by the calling thread in which case an "entry count" associated with the monitor is incremented. Calling unlock() on the monitor causes the entry count to be decremented, unlocking the mutex when it reaches zero. This provides the re-entrant semantics of the monitor.
Lock the mutex associated with the monitor.
If the calling thread already owns the mutex (has it locked) the entry count will be incremented by one.
Decrements the entry count associated with the monitor by one.
If it reaches zero, the mutex associated with the monitor is unlocked.
Wait for the monitor.