Skip to main content

Module oneshot

Module oneshot 

Source
Expand description

A channel that carries one value from one sender to one receiver, both on one shard.

The names, signatures and errors follow sync::oneshot, so code switches by changing the path. The state is one counted block of the thread’s cache (as an Rc, so no allocation in steady state) with a Cell of three bits (value sent, receiver closed, sender dropped), the value in a cell and the two wakers in cells: no atomic and no fence. The sender sends at most one value and never waits; the receiver is a Future that completes with the value, or with a RecvError when the sender is dropped without sending, and, like the atomic one, panics when polled again after it completed. A value that was sent and never received stays in the channel until the receiver is dropped, which drops it on the spot (outside any borrow).

A receive that completes spends one operation of the cooperative budget (see task::coop).

Re-exports§

pub use crate::sync::oneshot::error;

Structs§

Receiver
Receives the value of the Sender; a future.
Sender
Sends one value to the Receiver.

Functions§

channel
Creates a one-shot channel and answers its two halves.