pub struct TaskPool<V, P>where
P: Progressible,{ /* private fields */ }
Expand description
A pool to manage long-running tasks.
Implementations§
Source§impl<V, P> TaskPool<V, P>where
P: Progressible + Clone,
impl<V, P> TaskPool<V, P>where
P: Progressible + Clone,
Sourcepub fn with_lifespan(self, lifespan: Option<Duration>) -> Self
pub fn with_lifespan(self, lifespan: Option<Duration>) -> Self
Configure the lifespan of tasks.
None
means that tasks will never expire.
Expired tasks are purged as soon as complete
is invoked.
Specifying a lifespan is useful because clients might not always retrieve completed tasks.
Without configuring a lifespan, such abandoned tasks accumulate over time and fill up memory.
Sourcepub fn insert(&mut self, pending: P) -> (Handle, Uuid)
pub fn insert(&mut self, pending: P) -> (Handle, Uuid)
Insert a task’s initial progress to receive a Handle
and Uuid
referencing the task.
Sourcepub fn retrieve(&mut self, uuid: &Uuid) -> Option<TaskState<V, P>>
pub fn retrieve(&mut self, uuid: &Uuid) -> Option<TaskState<V, P>>
Get the task state and remove it from the pool if it is done.
Trait Implementations§
Auto Trait Implementations§
impl<V, P> Freeze for TaskPool<V, P>
impl<V, P> RefUnwindSafe for TaskPool<V, P>where
P: RefUnwindSafe,
V: RefUnwindSafe,
impl<V, P> Send for TaskPool<V, P>
impl<V, P> Sync for TaskPool<V, P>
impl<V, P> Unpin for TaskPool<V, P>
impl<V, P> UnwindSafe for TaskPool<V, P>where
P: UnwindSafe,
V: UnwindSafe,
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
Mutably borrows from an owned value. Read more