The Semaphore class is similar to the inbuilt Signal() class (and can be used as a replacement).
However, it also allows the thread issuing the signal to optionally post a value. Client threads
can optionally post expressions as they enter the :wait() state.
The expression is evaluated against the value posted by the signalling thread.
When a signal is received,
the client thread is only released if the expression evaluates TRUE.
In addition, each client thread can post it's own unique expression, so a single signal
can be used to selectively release client threads.
|