pub struct GenericOneshotBroadcastChannel<MutexType: RawMutex, T> { /* private fields */ }
Expand description
A channel which can be used to exchange a single value between two or more concurrent tasks.
The value which gets sent will get stored inside the Channel, and can be retrieved by an arbitrary number of tasks afterwards.
Tasks can wait for the value to get delivered via receive
.
The returned Future will get fulfilled when a value is sent into the channel.
Implementations
sourceimpl<MutexType: RawMutex, T> GenericOneshotBroadcastChannel<MutexType, T>where
T: Clone,
impl<MutexType: RawMutex, T> GenericOneshotBroadcastChannel<MutexType, T>where
T: Clone,
sourcepub fn new() -> GenericOneshotBroadcastChannel<MutexType, T>
pub fn new() -> GenericOneshotBroadcastChannel<MutexType, T>
Creates a new OneshotBroadcastChannel in the given state
sourcepub fn send(&self, value: T) -> Result<(), ChannelSendError<T>>
pub fn send(&self, value: T) -> Result<(), ChannelSendError<T>>
Writes a single value to the channel.
This will notify waiters about the availability of the value. If a value had been written to the channel before, or if the channel is closed, the new value will be rejected and returned inside the error variant.
sourcepub fn close(&self) -> CloseStatus
pub fn close(&self) -> CloseStatus
Closes the channel.
This will notify waiters about closure, by fulfilling pending Future
s
with None
.
send(value)
attempts which follow this call will fail with a
ChannelSendError
.
sourcepub fn receive(&self) -> ChannelReceiveFuture<'_, MutexType, T>ⓘNotable traits for ChannelReceiveFuture<'a, MutexType, T>impl<'a, MutexType, T> Future for ChannelReceiveFuture<'a, MutexType, T> type Output = Option<T>;
pub fn receive(&self) -> ChannelReceiveFuture<'_, MutexType, T>ⓘNotable traits for ChannelReceiveFuture<'a, MutexType, T>impl<'a, MutexType, T> Future for ChannelReceiveFuture<'a, MutexType, T> type Output = Option<T>;
Returns a future that gets fulfilled when a value is written to the channel or the channel is closed.