pub struct ProcessRegistry { /* private fields */ }Expand description
A thread-safe registry of all running processes.
The registry maintains mappings from:
- PIDs to process handles
- Registered names to PIDs
§Examples
use starlang_runtime::ProcessRegistry;
let registry = ProcessRegistry::new();
// Processes are registered when spawned via the runtimeImplementations§
Source§impl ProcessRegistry
impl ProcessRegistry
Sourcepub fn register(&self, handle: ProcessHandle)
pub fn register(&self, handle: ProcessHandle)
Registers a process in the registry.
Sourcepub fn unregister(&self, pid: Pid) -> Option<ProcessHandle>
pub fn unregister(&self, pid: Pid) -> Option<ProcessHandle>
Removes a process from the registry.
Also removes any name registrations for this process.
Sourcepub fn get(&self, pid: Pid) -> Option<ProcessHandle>
pub fn get(&self, pid: Pid) -> Option<ProcessHandle>
Gets a handle to a process by PID.
Sourcepub fn send_raw(&self, pid: Pid, data: Vec<u8>) -> Result<(), SendError>
pub fn send_raw(&self, pid: Pid, data: Vec<u8>) -> Result<(), SendError>
Sends a raw message to a process.
If the PID refers to a remote process and distribution is configured, the message will be routed through the distribution layer.
Sourcepub fn send<M: Term>(&self, pid: Pid, msg: &M) -> Result<(), SendError>
pub fn send<M: Term>(&self, pid: Pid, msg: &M) -> Result<(), SendError>
Sends a typed message to a process.
Sourcepub fn register_name(&self, name: String, pid: Pid) -> bool
pub fn register_name(&self, name: String, pid: Pid) -> bool
Registers a name for a process.
Returns false if the name is already registered.
Sourcepub fn unregister_name(&self, name: &str) -> Option<Pid>
pub fn unregister_name(&self, name: &str) -> Option<Pid>
Unregisters a name.
Returns the PID that was registered, if any.
Sourcepub fn registered_names(&self) -> Vec<String>
pub fn registered_names(&self) -> Vec<String>
Returns all registered names.
Sourcepub fn for_each<F>(&self, f: F)where
F: FnMut(ProcessHandle),
pub fn for_each<F>(&self, f: F)where
F: FnMut(ProcessHandle),
Iterates over all processes, calling the provided function.
Trait Implementations§
Source§impl Clone for ProcessRegistry
impl Clone for ProcessRegistry
Source§fn clone(&self) -> ProcessRegistry
fn clone(&self) -> ProcessRegistry
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ProcessRegistry
impl Debug for ProcessRegistry
Auto Trait Implementations§
impl !RefUnwindSafe for ProcessRegistry
impl !UnwindSafe for ProcessRegistry
impl Freeze for ProcessRegistry
impl Send for ProcessRegistry
impl Sync for ProcessRegistry
impl Unpin for ProcessRegistry
impl UnsafeUnpin for ProcessRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more