pub struct FiberHandle<A, E> { /* private fields */ }Expand description
Runtime-owned handle to a spawned fiber.
Completion is backed by Deferred (watch-channel rendezvous). Self::join and
Self::await_exit surface completion; Self::await_exit returns the full Exit value.
Implementations§
Source§impl<A, E> FiberHandle<A, E>
impl<A, E> FiberHandle<A, E>
Sourcepub fn pending(id: FiberId) -> Self
pub fn pending(id: FiberId) -> Self
Handle for a fiber not yet completed (waits on internal Deferred).
Sourcepub fn completed(id: FiberId, result: Result<A, E>) -> Self
pub fn completed(id: FiberId, result: Result<A, E>) -> Self
Handle already completed with result.
Sourcepub fn mark_completed(&self, result: Result<A, E>)
pub fn mark_completed(&self, result: Result<A, E>)
Complete the underlying deferred with result (for tests / manual drivers).
Sourcepub fn interrupt(&self) -> bool
pub fn interrupt(&self) -> bool
Fail the fiber with Cause::Interrupt. Returns false if already completed.
Sourcepub fn status(&self) -> FiberStatus
pub fn status(&self) -> FiberStatus
Running vs terminal outcome (blocking poll of the deferred).
Sourcepub fn is_done(&self) -> bool
pub fn is_done(&self) -> bool
true when Self::status is not FiberStatus::Running.
Sourcepub fn poll(&self) -> Effect<Option<Exit<A, E>>, Never, ()>
pub fn poll(&self) -> Effect<Option<Exit<A, E>>, Never, ()>
Non-blocking read of the current Exit, if the fiber has completed.
Sourcepub fn poll_result(&self) -> Option<Result<A, Cause<E>>>
pub fn poll_result(&self) -> Option<Result<A, Cause<E>>>
Snapshot for callers that want the legacy Option<Result<_, Cause>> shape: None while
running or when the stored exit is an interrupt (matches older FiberHandle::poll).
Sourcepub async fn join(&self) -> Result<A, Cause<E>>
pub async fn join(&self) -> Result<A, Cause<E>>
Await completion and map to Result (interrupt surfaces as Cause::Interrupt).
Sourcepub fn map<B>(
self,
f: impl Fn(A) -> B + Send + Sync + 'static,
) -> FiberHandle<B, E>
pub fn map<B>( self, f: impl Fn(A) -> B + Send + Sync + 'static, ) -> FiberHandle<B, E>
Map a successful value after this fiber completes (spawns a background join on the tokio runtime).
Sourcepub fn zip<B>(self, other: FiberHandle<B, E>) -> FiberHandle<(A, B), E>
pub fn zip<B>(self, other: FiberHandle<B, E>) -> FiberHandle<(A, B), E>
Zip two fibers; both must succeed. The first failure Cause wins.
Sourcepub fn zip_with<B, C, F>(
self,
other: FiberHandle<B, E>,
f: F,
) -> FiberHandle<C, E>
pub fn zip_with<B, C, F>( self, other: FiberHandle<B, E>, f: F, ) -> FiberHandle<C, E>
Like Self::zip, then combine success values with f.
Sourcepub fn or_else(self, other: FiberHandle<A, E>) -> FiberHandle<A, E>
pub fn or_else(self, other: FiberHandle<A, E>) -> FiberHandle<A, E>
Race: complete with whichever fiber finishes first (the other keeps running for other waiters).
Trait Implementations§
Source§impl<A: Clone, E: Clone> Clone for FiberHandle<A, E>
impl<A: Clone, E: Clone> Clone for FiberHandle<A, E>
Source§fn clone(&self) -> FiberHandle<A, E>
fn clone(&self) -> FiberHandle<A, E>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more