Skip to main content

FlowHandle

Struct FlowHandle 

Source
pub struct FlowHandle { /* private fields */ }
Expand description

A reference to a spawned flow, returned by super::runtime::Runtime::spawn.

Holding a FlowHandle does not keep the flow alive — it is a way to (a) read its FlowId for addressing with Send, and (b) block the calling native thread until it finishes via FlowHandle::join. Dropping without joining is fine (fire-and-forget).

Implementations§

Source§

impl FlowHandle

Source

pub fn id(&self) -> FlowId

Source

pub fn join(self) -> FlowOutcome

Block the current (native) thread until the flow terminates.

Never call from inside a worker / from a native invoked by bytecode. That case is machine-checked: this returns FlowOutcome::Failed with JoinError::CalledFromWorker rather than deadlocking the pool.

Returns FlowOutcome::Failed rather than blocking forever if the flow was destroyed without producing an outcome. super::runtime::Runtime::shutdown finalizes remaining flows (runtime shutdown); a dropped sender without finalize is super::error::RuntimeError::Abandoned.

Source

pub fn join_checked(self) -> Result<FlowOutcome, JoinError>

Same as Self::join, but surfaces JoinError instead of folding it into FlowOutcome::Failed.

Source

pub fn try_join(&self) -> Option<FlowOutcome>

The outcome if the flow has already terminated, None if it is still running. Never waits.

For embedders that drive their own loop and cannot surrender a thread to FlowHandle::join. Takes &self, so it can be polled until it answers; note that the outcome is handed out exactly once, and a further poll after that reports super::error::RuntimeError::AlreadyCollected as FlowOutcome::Failed rather than repeating it.

Source

pub fn join_timeout(&self, timeout: Duration) -> Option<FlowOutcome>

Wait up to timeout for the flow to terminate; None if it is still running when the bound elapses.

This is the variant to reach for in anything with a deadline — a control loop, a watchdog, a test harness — since it is the only join whose worst-case duration the caller chooses.

Source

pub fn join_deadline(&self, deadline: Instant) -> Option<FlowOutcome>

FlowHandle::join_timeout against an absolute deadline, for callers that already track one and must not have it drift across repeated waits.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.