pub fn channel<T: Send + 'static>(bound: usize) -> (Sender<T>, Receiver<T>)Expand description
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.
This channel has an internal buffer on which messages will be queued.
bound specifies the buffer size. When the internal buffer becomes full,
future sends will block waiting for the buffer to open up. Note that a
buffer size of 0 is valid, in which case this becomes “rendezvous channel”
where each send will not return until a recv is paired with it.
Both Sender and Receiver can be cloned to send or recv to
the same channel multiple times.
If the Receiver is disconnected while trying to send with the
Sender, the send method will return a SendError. Similarly, If
the Sender is disconnected while trying to recv, the recv method
will return a RecvError.