async-channel.ss: Buffered Asynchronous Channels
To load: (require (lib "async-channel.ss"))
This library implemented buffered asynchronous channels to complement MzScheme's synchronous channels (see section 7.5 in PLT MzScheme: Language Manual).
(make-async-channel [limit-k]) PROCEDURE
Returns an asynchronous channel with a buffer limit of limit-k
items. A get operation blocks when the channel is empty, and a put
operation blocks when the channel has limit-k items already.
If limit-k is #f (the default), the channel buffer has
no limited (so a put never blocks). Otherwise, limit-k must be
a positive exact integer.
The asynchronous channel value can be used directly with sync
(see section 7.7 in PLT MzScheme: Language Manual). The channel blocks until
async-channel-get would return a value, and the unblock
result is the received value.
(async-channel-get async-channel) PROCEDURE
Blocks until at least one value is available in async-channel,
and then returns the first of the values that was put
into async-channel.
(async-channel-try-get async-channel) PROCEDURE
If at least one value is immediately available in async-channel,
returns the first of the values that was put
into async-channel. If async-channel is empty, the result
is #f.
(async-channel-put async-channel v) PROCEDURE
Puts v into async-channel, blocking
if async-channel's buffer is full until space is available.
The result is void.
(async-channel-put-evt async-channel v) PROCEDURE
Returns a synchronizable event that is blocked while
(async-channel-put would
block. The unblock result is the event itself. See also
section 7.7 in PLT MzScheme: Language Manual.async-channel v)