3API
8.18
top
← prev up next →

rx-tx-async-channelπŸ”— i

David K. Storrs

1DescriptionπŸ”— i

Defines a struct containing two async-channels in order to make bi-directional communication simple. Relies on the struct-plus-plus module.

The two fields are called to-child and to-parent with the intent that the struct is created in one thread (the parent) and given to another thread (the child), and the fields specify who is expected to receive the messages–the parent thread receives messages that are put on to-parent and vice versa.

2SynopsisπŸ”— i

> (require struct-plus-plusracket/async-channelrx-tx-async-channel)
;The rx-tx-async-channel struct was defined via struct-plus-plus, meaning
;it has a keyword constructor and dotted accessors in addition to the normal
;`struct`-generated versions.
;
;Both #:to-child and #:to-parent are optional, so the following are essentially equivalent:
> (define x1(rx-tx-async-channel++ #:to-child(make-async-channel)#:to-parent(make-async-channel)))
;Obviously, you can also specify one argument and let the other default.
> (rx-tx-async-channel?ch)

#t

> (async-channel?(rx-tx-async-channel.to-child ch))

#t

> (async-channel?(rx-tx-async-channel.to-parent ch))

#t

> (async-channel-putparent1)
> (async-channel-putparent2)
> (async-channel-putparent3)
> (async-channel-putchild'a)
> (async-channel-putchild'b)
> (async-channel-putchild'c)
> (async-channel-getparent)

1

> (async-channel-getchild)

'a

3

'c

3APIπŸ”— i

procedure

( rx-tx-async-channel++ #:to-childasync-channel?
#:to-parentasync-channel)
rx-tx-async-channel?
async-channel?:(make-async-channel)
async-channel:(make-async-channel)
Keyword constructor.

procedure

( rx-tx-async-channel.to-child rtc)async-channel?

rtc:rx-tx-async-channel?
Dotted accessor created by struct-plus-plus.

procedure

( rx-tx-async-channel.to-parent rtc)async-channel?

rtc:rx-tx-async-channel?
Dotted accessor created by struct-plus-plus.

ch:async-channel?
Read from the async channel. If no messages are available, return #f. Otherwise, read repeatedly until no messages remain, then return the last message.

top
← prev up next →

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /