On this page:
async-channel?
make-async-channel
async-channel-get
async-channel-try-get
async-channel-put
async-channel-put-evt
Version: 4.1
10.2.4 Buffered Asynchronous Channels

 (require scheme/async-channel)

The bindings documented in this section are provided by the scheme/async-channel library, not scheme/base or scheme.

See also Thread Mailboxes.

(async-channel? v)  boolean?

  v : any/c

Returns #t if v is an asynchronous channel, #f otherwise.

(make-async-channel [limit])  async-channel?

  limit : (or/c exact-positive-integer? false/c) = #f

Returns an asynchronous channel with a buffer limit of limit items. A get operation blocks when the channel is empty, and a put operation blocks when the channel has limit items already. If limit is #f, the channel buffer has no limit (so a put never blocks).

The asynchronous channel value can be used directly with sync. The channel blocks until async-channel-get would return a value, and the unblock result is the received value.

(async-channel-get ach)  any/c

  ach : async-channel?

Blocks until at least one value is available in ach, and then returns the first of the values that were put into async-channel.

(async-channel-try-get ach)  any/c

  ach : async-channel?

If at least one value is immediately available in ach, returns the first of the values that were put into ach. If async-channel is empty, the result is #f.

(async-channel-put ach v)  void?

  ach : async-channel?

  v : any/c

Puts v into ach, blocking if ach’s buffer is full until space is available.

(async-channel-put-evt async-channel v)  evt?

  async-channel : channel?

  v : any/c

Returns a synchronizable event that is blocked while (async-channel-put ach v) would block. The unblock result is the event itself. See also sync.