Next: , Previous: , Up: Fibers   [Contents][Index]


4.14.3 Channels

Channels are the way to communicate between fibers. To use them, load the (fibers channels) module.

Procedure: make-channel

Make a fresh channel.

Procedure: channel? obj

Return #t if obj is a channel, or #f otherwise.

Procedure: put-operation channel message

Make an operation that if and when it completes will rendezvous with a receiving operation to send message over channel.

Procedure: get-operation channel

Make an operation that if and when it completes will rendezvous with a sending operation to receive one value from channel.

Procedure: put-message channel message

Send message on channel, and return zero values. If there is already a receiver waiting to receive a message on this channel, give it our message and continue. Otherwise, block until a receiver becomes available.

Equivalent to:

(perform-operation (put-operation channel message))
Procedure: get-message channel

Receive a message from channel and return it. If there is already a sender waiting to send a message on this channel, take its message directly. Otherwise, block until a sender becomes available.

Equivalent to:

(perform-operation (get-operation channel))