Skip to main content

System

Struct System 

Source
pub struct System {
    pub undeliverable: Vec<(Pid, Value)>,
    /* private fields */
}
Expand description

The host state a blue process tree runs against.

Mailboxes live here rather than on the crate::Supervisor on purpose: the supervisor owns the processes and hands &mut H to Vm::step, so a supervisor-owned mailbox map would be borrowed twice at once.

Fields§

§undeliverable: Vec<(Pid, Value)>

Sends to a pid with no mailbox. Kept rather than dropped so a misdirected message is diagnosable instead of invisible.

Implementations§

Source§

impl System

Source

pub fn new() -> Self

Source

pub fn register(&mut self, pid: Pid)

Give pid a mailbox. Called by the supervisor on spawn.

Source

pub fn current(&self) -> Pid

Source

pub fn send(&mut self, to: Pid, msg: Value)

Enqueue a deep copy of msg.

Value is Arc-based, so pushing it as-is would share structure between two processes and quietly reintroduce exactly the coupling that separate interpreters removed. Copying at the boundary is what makes “processes share nothing” true rather than nearly true.

Source

pub fn has_mail(&self, pid: Pid) -> bool

Source

pub fn mail_count(&self, pid: Pid) -> usize

Source

pub fn clear(&mut self, pid: Pid)

Empty a mailbox. A restarted process starts with a clean one: the messages that were in flight when it crashed were addressed to the incarnation that died, and replaying them into the fresh one is how a poison message takes down a process forever.

Source

pub fn any_mail(&self) -> bool

Is any mailbox non-empty? Used to tell a live wait from a deadlock.

Trait Implementations§

Source§

impl Debug for System

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for System

Source§

fn default() -> System

Returns the “default value” for a type. Read more
Source§

impl Readiness for System

Source§

fn is_ready(&self, pid: Pid) -> bool

May this parked process now make progress?
Source§

fn any_pending(&self) -> bool

Is there any pending work at all? When every process is parked and this is false, nothing will ever change: that is a deadlock, and spinning on it forever is the failure mode this question exists to prevent.
Source§

fn set_current(&mut self, pid: Pid)

The scheduler is about to give pid a slice. A host whose primitives are process-relative — receive, self — needs this to answer them. Default: nothing.
Source§

fn on_restart(&mut self, pid: Pid)

pid is about to restart, so its per-process host state should be discarded. Default: nothing.

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