pub struct StopTask<'a> { /* private fields */ }Expand description
A future indicating that the task should return for event processing or because the task was stopped.
See the worker cancellation guide.
Implementations§
Source§impl<'a> StopTask<'a>
impl<'a> StopTask<'a>
Sourcepub async fn run_unstoppable<R>(
f: impl AsyncFnOnce(&mut StopTask<'_>) -> R,
) -> R
pub async fn run_unstoppable<R>( f: impl AsyncFnOnce(&mut StopTask<'_>) -> R, ) -> R
Runs f with a task that never receives control requests.
Intended for test helpers that run a device without a TaskControl.
Sourcepub fn check(&self) -> Result<(), Cancelled>
pub fn check(&self) -> Result<(), Cancelled>
Checks whether the task should return for stop or event processing.
Call at cancel-safe boundaries in loops that can keep making progress
without yielding. This does not yield or cancel an outstanding wait;
use Self::until_stopped for waits that must be interruptible.
This only performs a relaxed atomic load. Request producers publish the signal directly; checking does not register or poll a waker.
Sourcepub fn check_handle(&self) -> Result<StopCheck<'a>, Cancelled>
pub fn check_handle(&self) -> Result<StopCheck<'a>, Cancelled>
Checks for a request and returns a handle for this worker activation.
Use this inside a future passed to Self::until_stopped, or when
several processing loops need to check the same control request.
Sourcepub async fn until_stopped<F: Future>(
&mut self,
fut: F,
) -> Result<F::Output, Cancelled>
pub async fn until_stopped<F: Future>( &mut self, fut: F, ) -> Result<F::Output, Cancelled>
Runs fut until the task is requested to stop.
If fut completes, then Ok(_) is returned.
If the task is requested to stop before fut completes, then fut is
dropped and Err(Cancelled) is returned.
Stop takes priority when both stop and work are ready.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for StopTask<'a>
impl<'a> !RefUnwindSafe for StopTask<'a>
impl<'a> Send for StopTask<'a>
impl<'a> !Sync for StopTask<'a>
impl<'a> Unpin for StopTask<'a>
impl<'a> UnsafeUnpin for StopTask<'a>
impl<'a> !UnwindSafe for StopTask<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn map<U, F>(self, f: F) -> Map<Self, F>
fn map<U, F>(self, f: F) -> Map<Self, F>
§fn map_into<U>(self) -> MapInto<Self, U>
fn map_into<U>(self) -> MapInto<Self, U>
§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
f. Read more§fn left_future<B>(self) -> Either<Self, B>
fn left_future<B>(self) -> Either<Self, B>
§fn right_future<A>(self) -> Either<A, Self>
fn right_future<A>(self) -> Either<A, Self>
§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll will never again be called once it has
completed. This method can be used to turn any Future into a
FusedFuture. Read more§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
§fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
() on completion and sends
its output to another future on a separate task. Read more§fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
§fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
§fn unit_error(self) -> UnitError<Self>where
Self: Sized,
fn unit_error(self) -> UnitError<Self>where
Self: Sized,
Future<Output = T> into a
TryFuture<Ok = T, Error = ()>.§fn never_error(self) -> NeverError<Self>where
Self: Sized,
fn never_error(self) -> NeverError<Self>where
Self: Sized,
Future<Output = T> into a
TryFuture<Ok = T, Error = Never>.