pub struct TaskHandle<T, E: TError> {
pub rx: Receiver<T>,
pub ctx: Context<E>,
}Fields§
§rx: Receiver<T>§ctx: Context<E>Implementations§
Source§impl<T, E: TError> TaskHandle<T, E>
impl<T, E: TError> TaskHandle<T, E>
pub fn stop(self) -> FutureTaskState<E>
pub fn wait_for_stopped(self) -> impl Future<Output = Result<(), TaskError<E>>>
Sourcepub async fn recv(&mut self) -> Option<T>
pub async fn recv(&mut self) -> Option<T>
Receives the next value for this receiver.
This method returns None if the channel has been closed and there are
no remaining messages in the channel’s buffer. This indicates that no
further values can ever be received from this Receiver. The channel is
closed when all senders have been dropped, or when close is called.
If there are no messages in the channel’s buffer, but the channel has
not yet been closed, this method will sleep until a message is sent or
the channel is closed. Note that if close is called, but there are
still outstanding Permits from before it was closed, the channel is
not considered closed by recv until the permits are released.
§Cancel safety
This method is cancel safe. If recv is used as the event in a
tokio::select! statement and some other branch
completes first, it is guaranteed that no messages were received on this
channel.
Sourcepub fn blocking_recv(&mut self) -> Option<T>
pub fn blocking_recv(&mut self) -> Option<T>
Blocking receive to call outside of asynchronous contexts.
This method returns None if the channel has been closed and there are
no remaining messages in the channel’s buffer. This indicates that no
further values can ever be received from this Receiver. The channel is
closed when all senders have been dropped, or when close is called.
If there are no messages in the channel’s buffer, but the channel has not yet been closed, this method will block until a message is sent or the channel is closed.
This method is intended for use cases where you are sending from
asynchronous code to synchronous code, and will work even if the sender
is not using blocking_send to send the message.
Note that if close is called, but there are still outstanding
Permits from before it was closed, the channel is not considered
closed by blocking_recv until the permits are released.