Expand description
A multi-producer, single-consumer queue for sending requests across asynchronous tasks.
Channel creation provides Receiver
and Sender
handles. Sender
can make requests that
await a response from the Receiver
. Every message sent across the channel is packaged with
a Responder
that is used to respond to that request. A Sender
will wait until a response is
received before Sender::request
completes.
§Disconnection
When all Sender
handles have been dropped, it is no longer possible to send requests into the
channel. As such, Receiver::receive
will return an error.
§Clean Shutdown
If a Receiver
is dropped, it is possible for there to be messages in the channel that will
never be processed. If a clean shutdown is desired, a receiver can first call Receiver::close
to prevent further messages from being sent into the channel. Then, the receiver can handle all
messages in the channel and be dropped.
Structs§
- The responding end of a channel.
- Responds to a single request with a value.
- The requesting end of a channel.
Functions§
- Create a new asynchronous channel with a bounded capacity, returning the sender/receiver halves.