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 asychronous channel value can be used directly
with object-wait-multiple
(see section 7.6 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.
(make-async-channel-put-waitable
async-channel v
)
PROCEDURE
Returns a waitable object that is blocked
while (async-channel-put
would
block. The unblock result is the waitable object itself.
See also section 7.6 in PLT MzScheme: Language Manual.async-channel
v
)