-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
terminate actor with no more messages guarantee #104
Comments
@aav can you confirm that this is the case? |
@leenozara |
Here is the code example: use std::time::Duration;
use riker::actors::*;
#[derive(Default)]
struct MyActor;
impl Actor for MyActor {
type Msg = i32;
fn recv(&mut self, ctx: &Context<Self::Msg>, msg: Self::Msg, _sender: Sender) {
println!("message: {:?}", msg);
if msg == 5 {
println!("stop");
ctx.stop(ctx.myself());
}
}
}
fn main() {
let sys = ActorSystem::new().unwrap();
let actor = sys.actor_of::<MyActor>("actor").unwrap();
for n in 0..10 {
actor.tell(n, None);
}
std::thread::sleep(Duration::from_millis(5000));
} and here is the output:
I would expect that after |
Thanks for checking and confirming that. I’ll take a look to see why this is the case. |
@aav did you happen to find a solution to this? I'm currently struggling with a similar situation where even though we're calling Update: for some reason everything works as expected when using |
Currently, there is no way to terminate the actor from recv callback in a way, that no messages will arrive (recv will not be called) after termination. Clearly
ctx.stop(ctx.myself());
does not satisfy this criteria.Here is the typical use case:
In Erlang, I would simply stop receiving messages and leave the process function. Since here we are based on callback, I believe that such a function is really important.
The text was updated successfully, but these errors were encountered: