Signaling with Wait and Pulse
In one of our previous examples, we've used the
Lock class whose implementation uses
Monitor::Exit. Another feature of the
Monitor object is very important: the
Monitor::Pulse methods (and the
PulseAll). These methods also make EAP constructs. Their ability to wait until a signal is received from another thread makes them excellent for usage. One of the most important features is that they prevent spinning, because of which no processor time is wasted. The only constraint is that they must be enclosed with locks (
Monitor::Exit). Once again, we're introducing the
Lock class in order to gain exclusive access to shared objects.
Our following example ...