Module keos::thread::channel

source ·
Expand description

Multi-producer, multi-consumer FIFO queue communication primitives.

This module provides message-based communication over channels, concretely defined among two types:

A Sender is used to send data to a Receiver. Both sender and receiver are clone-able (multi-producer) such that many threads can send simultaneously to multiple receiver (multi-consumer).

Disconnection

The send and receive operations on channels will all return a [Result] indicating whether the operation succeeded or not. An unsuccessful operation is normally indicative of the other half of a channel having “hung up” by being dropped in its corresponding thread.

Once half of a channel has been deallocated, most operations can no longer continue to make progress, so [Err] will be returned. Many applications will continue to unwrap the results returned from this module, instigating a propagation of failure among threads if one unexpectedly dies.

Structs

An owning iterator over messages on a Receiver, created by Receiver::into_iter.
An iterator over messages on a Receiver, created by iter.
Helper structure to get response directly by polling this object.
The receiving half of channel type. This half can only be owned by one thread, but it can be cloned to receive to other threads.
An error returned from the recv function on a Receiver.
An error returned from the Sender::send function on channels.
The sending-half of channel type. This half can only be owned by one thread, but it can be cloned to send to other threads.
An iterator that attempts to yield all pending values for a Receiver, created by try_iter.

Enums

This enumeration is the list of the possible reasons that try_recv could not return data when called. This can occur with a channel.
This enumeration is the list of the possible error outcomes for the try_send method.

Functions

Creates a new bounded channel. All data sent on the Sender will become available on the Receiver in the same order as it was sent. Like asynchronous channels, the Receiver will block until a message becomes available.