Channels are a tool for communicating amongst different scripts. One script can write a value to the channel and another can read from it. Reading or writing to a channel suspends that script until there is someone on the other end of the line to complete the transaction.
Here’s a simplistic example:
(define c (make-channel)) (script (forever (let ((item (channel-get c))) (pk 'got item)))) (script (channel-put c 'sword) (channel-put c 'shield) (channel-put c 'potion))
Return a new channel
Return #t
if obj is a channel.
Retrieve a value from channel. The current script suspends until a value is available.
Send data to channel. The current script suspends until another script is available to retrieve the value.
A low-level API also exists for using channels outside of a script via callback procedures:
Asynchronously retrieve a value from channel and call proc with that value.
Asynchronously send data to channel and call thunk after it has been received.
Clear all messages and scripts awaiting messages in channel.