Skip to main content

ProcessHandle

Struct ProcessHandle 

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

A handle to a running process.

This handle can be cloned and shared between threads. It provides methods for sending messages and managing process relationships.

Implementations§

Source§

impl ProcessHandle

Source

pub fn new( pid: Pid, sender: MailboxSender, state: Arc<RwLock<ProcessState>>, termination_tx: Option<Sender<ExitReason>>, ) -> Self

Creates a new process handle.

Source

pub fn pid(&self) -> Pid

Returns the process identifier.

Source

pub fn send_raw(&self, data: Vec<u8>) -> Result<(), SendError>

Sends a raw message (bytes) to the process.

Source

pub fn send<M: Term>(&self, msg: &M) -> Result<(), SendError>

Sends a typed message to the process.

Source

pub fn is_alive(&self) -> bool

Returns true if the process is still alive.

Source

pub fn is_trapping_exits(&self) -> bool

Returns true if the process is trapping exits.

Source

pub fn set_trap_exit(&self, trap: bool)

Sets the trap_exit flag.

Adds a link to another process.

Links are bidirectional - this only updates our side. The caller must also update the other process.

Removes a link to another process.

Returns all linked processes.

Source

pub fn add_monitor(&self, reference: Ref, target: Pid)

Adds a monitor (we are monitoring target).

Source

pub fn remove_monitor(&self, reference: Ref) -> Option<Pid>

Removes a monitor.

Source

pub fn add_monitored_by(&self, reference: Ref, monitoring_pid: Pid)

Adds a process that is monitoring us.

Source

pub fn remove_monitored_by(&self, reference: Ref) -> Option<Pid>

Removes a process from our monitored_by set.

Source

pub fn monitored_by(&self) -> Vec<(Ref, Pid)>

Returns all processes monitoring this one.

Source

pub fn mark_terminated(&self, reason: ExitReason)

Marks the process as terminated.

Source

pub fn exit_reason(&self) -> Option<ExitReason>

Returns the exit reason if the process has terminated.

Trait Implementations§

Source§

impl Clone for ProcessHandle

Source§

fn clone(&self) -> ProcessHandle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProcessHandle

Source§

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

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.