extern crate riker; use riker::actors::*; use std::time::Duration; #[derive(Clone, Debug)] pub struct Panic; #[derive(Default)] struct DumbActor; impl Actor for DumbActor { type Msg = (); fn recv(&mut self, _: &Context, _: Self::Msg, _: Sender) {} } #[actor(Panic)] #[derive(Default)] struct PanicActor; impl Actor for PanicActor { type Msg = PanicActorMsg; fn pre_start(&mut self, ctx: &Context) { ctx.actor_of::("child_a").unwrap(); ctx.actor_of::("child_b").unwrap(); ctx.actor_of::("child_c").unwrap(); ctx.actor_of::("child_d").unwrap(); } fn recv(&mut self, ctx: &Context, msg: Self::Msg, sender: Sender) { self.receive(ctx, msg, sender); } } impl Receive for PanicActor { type Msg = PanicActorMsg; fn receive(&mut self, _ctx: &Context, _msg: Panic, _sender: Sender) { panic!("// TEST PANIC // TEST PANIC // TEST PANIC //"); } } fn main() { let sys = SystemBuilder::new().name("my-app").create().unwrap(); let sup = sys.actor_of::("panic_actor").unwrap(); // println!("Child not added yet"); // sys.print_tree(); println!("Before panic we see supervisor and actor that will panic!"); std::thread::sleep(Duration::from_millis(500)); sys.print_tree(); sup.tell(Panic, None); std::thread::sleep(Duration::from_millis(500)); println!("We should see panic printed, but we still alive and panic actor gone!"); sys.print_tree(); }