Struct futures_intrusive::channel::GenericOneshotChannel
source · pub struct GenericOneshotChannel<MutexType: RawMutex, T> { /* private fields */ }
Expand description
A channel which can be used to exchange a single value between two concurrent tasks.
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.
The value can only be extracted by a single receiving task. Once the value
has been retrieved from the Channel, the Channel is closed and subsequent
receive calls will return None
.
Implementations
sourceimpl<MutexType: RawMutex, T> GenericOneshotChannel<MutexType, T>
impl<MutexType: RawMutex, T> GenericOneshotChannel<MutexType, T>
sourcepub fn new() -> GenericOneshotChannel<MutexType, T>
pub fn new() -> GenericOneshotChannel<MutexType, T>
Creates a new OneshotChannel 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.