SourcePro : Threads Module User's Guide : PART II Concurrency Packages : The Interthread Communication Package
The Interthread Communication Package
Introducing the Interthread Communication Package
This chapter describes the thread communication mechanisms of Threads Module:
*IOUs
A function performs some operation that produces a result or value, and then returns that result to the function’s caller. Normal function invocations are synchronous, but they can also be asynchronous—they return to their caller before their associated operation has finished.
In the Interthread Communication package, asynchronous operations are possible through the use of IOUs, a communication mechanism that represents a future result of an operation. A function that launches an asynchronous operation can immediately return an IOU instance that is bound to the future result of that operation. This IOU instance can be redeemed at anytime, by any thread, to retrieve the result of the operation. If the operation has not yet completed, then the redeeming thread is blocked until a result has been produced.
For more information, see Using IOUs and The IOU Classes.
*Producer-Consumer Queues
The Interthread Communication package includes a family of templatized, value and pointer-based, queue and stack classes that use producer-consumer synchronization semantics to coordinate multithread access. Producer-consumer synchronization insures that a thread attempting to read from an empty buffer blocks until an entry is available, and that a thread attempting to write to a size-limited buffer that is full, blocks until an entry is removed or read by another thread.