agner_actors/actor_runner/
sys_msg.rs

1use tokio::sync::oneshot;
2
3use crate::actor_id::ActorID;
4use crate::exit::Exit;
5
6use super::Backend;
7
8#[derive(Debug)]
9pub enum SysMsg {
10    Link(ActorID),
11    Unlink(ActorID),
12    SigExit(ActorID, Exit),
13    GetInfo(oneshot::Sender<ActorInfo>),
14}
15
16/// Information about a running actor.
17///
18/// Returned as the result of introspection of an actor (See [`System::actor_info(&self,
19/// ActorID)`](crate::system::System::actor_info))
20#[derive(Debug, Clone)]
21#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
22pub struct ActorInfo {
23    pub actor_id: ActorID,
24    pub behaviour: &'static str,
25    pub args_type: &'static str,
26    pub message_type: &'static str,
27    pub m_queue_len: (usize, usize),
28    pub s_queue_len: (usize, usize),
29    pub c_queue_len: (usize, usize),
30    pub tasks_count: usize,
31    pub trap_exit: bool,
32    pub links: Box<[ActorID]>,
33}
34
35impl<M> Backend<M> {
36    pub(super) async fn send_sys_msg(&self, to: ActorID, sys_msg: SysMsg) -> bool {
37        if let Some(system) = self.system_opt.rc_upgrade() {
38            system.send_sys_msg(to, sys_msg).await
39        } else {
40            false
41        }
42    }
43}