Scenario: my actor registers a schedule and I was under the impression that I should cancel the schedule when the actor is shutting down. Unfortunately, Actor::post_stop doesn't have a reference to ActorSystem so I cannot cancel the schedule there.
It's possible that schedules for terminated actors get cleaned up automatically but during experimentation I realised that Actor::sys_recv doesn't get invoked even though the documentation suggests that it would be.
The following code only prints "Stopping the actor..." but not "System message!".
impl Actor for MyActor {
type Msg = MyActorMsg;
fn post_stop(&mut self) {
println!("Stopping the actor for {}", self.configuration.uri);
match self.schedule_id {
Some(schedule_id) => {
// TODO: how to cancel the schedule w/o reference to the ActorSystem?
// ctx.system.cancel_schedule(schedule_id);
}
None => {
warn!("Stopping the actor without any schedule running");
}
}
}
fn sys_recv(&mut self, ctx: &Context<Self::Msg>, msg: SystemMsg, sender: Sender) {
println!("System message!");
}
fn recv(&mut self, ctx: &Context<Self::Msg>, msg: Self::Msg, sender: Sender) {
self.receive(ctx, msg, sender)
}
}
Scenario: my actor registers a schedule and I was under the impression that I should cancel the schedule when the actor is shutting down. Unfortunately,
Actor::post_stop
doesn't have a reference toActorSystem
so I cannot cancel the schedule there.It's possible that schedules for terminated actors get cleaned up automatically but during experimentation I realised that
Actor::sys_recv
doesn't get invoked even though the documentation suggests that it would be.The following code only prints "Stopping the actor..." but not "System message!".