Struct JoinHandle

Source
pub struct JoinHandle<T> { /* private fields */ }
Expand description

An owned permission to join on a process (block on its termination).

The join handle can be used to join a process but also provides the ability to kill it.

Implementations§

Source§

impl<T> JoinHandle<T>

Source

pub fn pid(&self) -> Option<u32>

Returns the process ID if available.

The process ID is unavailable when pooled calls are not scheduled to processes.

Source

pub fn kill(&mut self) -> Result<(), SpawnError>

Kill the child process.

If the join handle was created from a pool this call will do one of two things depending on the situation:

  • if the call was already picked up by the process, the process will be killed.
  • if the call was not yet scheduled to a process it will be cancelled.
Source

pub fn stdin(&mut self) -> Option<&mut ChildStdin>

Fetch the stdin handle if it has been captured

Source

pub fn stdout(&mut self) -> Option<&mut ChildStdout>

Fetch the stdout handle if it has been captured

Source

pub fn stderr(&mut self) -> Option<&mut ChildStderr>

Fetch the stderr handle if it has been captured

Source§

impl<T: Serialize + DeserializeOwned> JoinHandle<T>

Source

pub fn join(self) -> Result<T, SpawnError>

Wait for the child process to return a result.

If the join handle was created from a pool the join is virtualized.

Source

pub fn join_timeout(&mut self, timeout: Duration) -> Result<T, SpawnError>

Like join but with a timeout.

Can be called multiple times. If anything other than a timeout error is returned, the handle becomes unusuable, and subsequent calls to either join or join_timeout will return an error.

Trait Implementations§

Source§

impl<T> Debug for JoinHandle<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for JoinHandle<T>

§

impl<T> !RefUnwindSafe for JoinHandle<T>

§

impl<T> Send for JoinHandle<T>
where T: Send,

§

impl<T> !Sync for JoinHandle<T>

§

impl<T> Unpin for JoinHandle<T>
where T: Unpin,

§

impl<T> !UnwindSafe for JoinHandle<T>

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.