pub struct SharedTaskSlot<T> { /* private fields */ }Expand description
Owns one typed task shared by cloned clients.
Concurrent finish calls are serialized within the caller’s graceful and abort durations. Canceling a finish or reaching the forced-completion deadline retains the task for another drain attempt. Dropping the owner requests abort but cannot asynchronously prove termination.
Implementations§
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns whether the slot owns no task, including while a drain is pending.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Returns whether the owned task has finished without being joined.
Returns false while a drain owns the handle and its state is unavailable.
Sourcepub fn insert(&self, handle: JoinHandle<T>)
pub fn insert(&self, handle: JoinHandle<T>)
Stores a task in an empty slot.
§Panics
Aborts handle and panics if the slot already owns a task or is draining one.
Sourcepub fn spawn<F>(&self, future: F) -> Result<(), TaskSpawnError>
pub fn spawn<F>(&self, future: F) -> Result<(), TaskSpawnError>
Sourcepub fn try_insert_slot(&self, slot: TaskSlot<T>) -> Result<(), TaskSlot<T>>
pub fn try_insert_slot(&self, slot: TaskSlot<T>) -> Result<(), TaskSlot<T>>
Transfers a task slot into this owner if it is empty.
An empty input slot is always accepted. Returns a nonempty input unchanged when this owner already has a task or is draining one.
§Errors
Returns the input slot when this owner already has a task or is draining one.
Sourcepub fn abort(&self)
pub fn abort(&self)
Requests task cancellation and records it as owner-initiated.
§Panics
Panics if the shared task slot changes while cancellation temporarily drains it.
Sourcepub async fn finish(
&self,
graceful_timeout: Duration,
abort_timeout: Duration,
) -> Option<TaskJoinOutcome<T>>
pub async fn finish( &self, graceful_timeout: Duration, abort_timeout: Duration, ) -> Option<TaskJoinOutcome<T>>
Gracefully joins the task, then aborts and joins it within a second bound.
If another caller holds the drain lock through both bounds, returns
TaskJoinOutcome::Incomplete when a task remains owned.
Trait Implementations§
Auto Trait Implementations§
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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