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
impl ProcessHandle
Sourcepub fn new(
pid: Pid,
sender: MailboxSender,
state: Arc<RwLock<ProcessState>>,
termination_tx: Option<Sender<ExitReason>>,
) -> Self
pub fn new( pid: Pid, sender: MailboxSender, state: Arc<RwLock<ProcessState>>, termination_tx: Option<Sender<ExitReason>>, ) -> Self
Creates a new process handle.
Sourcepub fn send_raw(&self, data: Vec<u8>) -> Result<(), SendError>
pub fn send_raw(&self, data: Vec<u8>) -> Result<(), SendError>
Sends a raw message (bytes) to the process.
Sourcepub fn send<M: Term>(&self, msg: &M) -> Result<(), SendError>
pub fn send<M: Term>(&self, msg: &M) -> Result<(), SendError>
Sends a typed message to the process.
Sourcepub fn is_trapping_exits(&self) -> bool
pub fn is_trapping_exits(&self) -> bool
Returns true if the process is trapping exits.
Sourcepub fn set_trap_exit(&self, trap: bool)
pub fn set_trap_exit(&self, trap: bool)
Sets the trap_exit flag.
Sourcepub fn add_link(&self, other: Pid)
pub fn add_link(&self, other: Pid)
Adds a link to another process.
Links are bidirectional - this only updates our side. The caller must also update the other process.
Sourcepub fn remove_link(&self, other: Pid)
pub fn remove_link(&self, other: Pid)
Removes a link to another process.
Sourcepub fn add_monitor(&self, reference: Ref, target: Pid)
pub fn add_monitor(&self, reference: Ref, target: Pid)
Adds a monitor (we are monitoring target).
Sourcepub fn remove_monitor(&self, reference: Ref) -> Option<Pid>
pub fn remove_monitor(&self, reference: Ref) -> Option<Pid>
Removes a monitor.
Sourcepub fn add_monitored_by(&self, reference: Ref, monitoring_pid: Pid)
pub fn add_monitored_by(&self, reference: Ref, monitoring_pid: Pid)
Adds a process that is monitoring us.
Sourcepub fn remove_monitored_by(&self, reference: Ref) -> Option<Pid>
pub fn remove_monitored_by(&self, reference: Ref) -> Option<Pid>
Removes a process from our monitored_by set.
Sourcepub fn monitored_by(&self) -> Vec<(Ref, Pid)>
pub fn monitored_by(&self) -> Vec<(Ref, Pid)>
Returns all processes monitoring this one.
Sourcepub fn mark_terminated(&self, reason: ExitReason)
pub fn mark_terminated(&self, reason: ExitReason)
Marks the process as terminated.
Sourcepub fn exit_reason(&self) -> Option<ExitReason>
pub fn exit_reason(&self) -> Option<ExitReason>
Returns the exit reason if the process has terminated.
Trait Implementations§
Source§impl Clone for ProcessHandle
impl Clone for ProcessHandle
Source§fn clone(&self) -> ProcessHandle
fn clone(&self) -> ProcessHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more