David K. Storrs
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.
;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:;Obviously, you can also specify one argument and let the other default.> (rx-tx-async-channel?ch)#t
#t
#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
procedure
#:to-parentasync-channel)→rx-tx-async-channel?async-channel?:(make-async-channel)async-channel:(make-async-channel)
procedure
( rx-tx-async-channel.to-child rtc)→async-channel?
rtc:rx-tx-async-channel?
procedure
( rx-tx-async-channel.to-parent rtc)→async-channel?
rtc:rx-tx-async-channel?
procedure
ch:async-channel?