//! Supervision signals. //! //! Every actor has a supervisor, which is itself just an actor with a //! `Receiver`. When a child actor terminates, the scheduler sends //! a `Signal` on the supervisor's channel. The supervisor decides what to //! do — restart, escalate, ignore. //! //! For v0.1 there is no built-in restart-intensity cap. That's policy and //! lives in user code; library is mechanism only. use crate::pid::Pid; use std::any::Any; pub enum Signal { /// The child exited normally. Exit(Pid), /// The child panicked. Payload is whatever `panic!` was called with. Panic(Pid, Box), } impl std::fmt::Debug for Signal { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Signal::Exit(pid) => write!(f, "Signal::Exit({:?})", pid), Signal::Panic(pid, _) => write!(f, "Signal::Panic({:?}, ..)", pid), } } } impl Signal { pub fn pid(&self) -> Pid { match self { Signal::Exit(p) => *p, Signal::Panic(p, _) => *p, } } }