Struct LatestTask
pub struct LatestTask<T> { /* private fields */ }Expand description
Typed state for restartable background work where only the latest run may
publish a result. Starting or cancelling a run invalidates every older
TaskCompletion.
Implementations§
§impl<T> LatestTask<T>
impl<T> LatestTask<T>
pub fn new(initial: T) -> LatestTask<T>
pub fn spawn<F>(&self, running: T, future: F) -> bool
pub fn spawn<F>(&self, running: T, future: F) -> bool
Publish running, then run future on the app runtime
(tilo_rt::app) and publish its output, waking the event loop.
The future never runs on the calling UI thread. Starting another run or cancelling aborts it at its next await point, and its output is discarded if it finishes anyway.
Returns false without spawning when Self::try_begin refuses.
pub fn state(&self) -> LocalState<T>
pub fn state(&self) -> LocalState<T>
Clone the observable state for ModelView, Text, or UI callbacks.
pub fn begin(&self, running: T) -> TaskCompletion<T>
pub fn begin(&self, running: T) -> TaskCompletion<T>
Begin a new run and return its background-safe completion capability.
Any earlier capability becomes stale before running is published.
After the generation namespace is exhausted this returns a permanently
stale capability which cannot publish. This preserves the original
infallible API without reissuing an aliased generation; use
Self::try_begin when exhaustion must be handled explicitly.
pub fn try_begin(&self, running: T) -> Option<TaskCompletion<T>>
pub fn try_begin(&self, running: T) -> Option<TaskCompletion<T>>
Fallible form of Self::begin. Some means the running state and a
unique task generation were accepted for publication; it does not mean
that a wake was delivered or scheduled. Returns None without
publishing when the captured owner is closed, the state revision
namespace is exhausted, or the task generation namespace is exhausted.
pub fn cancel(&self, cancelled: T)
pub fn cancel(&self, cancelled: T)
Invalidate the current run and publish its replacement state. A worker that finishes afterward cannot overwrite this value.
pub fn try_cancel(&self, cancelled: T) -> bool
pub fn try_cancel(&self, cancelled: T) -> bool
Fallible form of Self::cancel.
Trait Implementations§
§impl<T> Clone for LatestTask<T>
impl<T> Clone for LatestTask<T>
§fn clone(&self) -> LatestTask<T>
fn clone(&self) -> LatestTask<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<T> Freeze for LatestTask<T>
impl<T> RefUnwindSafe for LatestTask<T>
impl<T> Send for LatestTask<T>
impl<T> Sync for LatestTask<T>
impl<T> Unpin for LatestTask<T>
impl<T> UnsafeUnpin for LatestTask<T>
impl<T> UnwindSafe for LatestTask<T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more