Data *get() {
// lock the monitor
Wait on MonitorMutex
// test the Predicate
// which can be any arbitrary logical expression
While (there are no elements in the deque) {
--- OPERATING SYSTEM ATOMIC ---
SignalObjectAndWait(...)
// unlock the monitor
Signal MonitorMutex
// wait for a pulse from the 'put' method
Wait on event ElementAvailable
--- END OPERATING SYSTEM ATOMIC ---
// relock the monitor
Wait on MonitorMutex
}
// at this point it is guaranteed that MonitorMutex is locked and
// there is at least one element in the deque
p = get element...
// signal next putter that space is available
Pulse Event SpaceAvailable
// unlock the monitor
Signal MonitorMutex
// return the data value
Return p;
}