-
Notifications
You must be signed in to change notification settings - Fork 538
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
Implement a weak version of after
#1467
Comments
I do like your What about this idea?
Both versions would return a |
I like the UX of once/repeat. For strong/weak, however, I think it should just be weak. Making the strong version the default is a dangerous default, and if a user knows what they're doing and they want to opt into letting the actor keep a strong reference to itself, then they should probably do so explicitly: using foo_actor = typed_actor<...>;
// Given a `foo_actor::pointer self`:
self->when_idle(1s).once([self, keepalive=foo_actor{self}] {
// ...
}); The same also applies to |
I think having However, I wouldn't mind just making it explicit in all cases, i.e., not provide a default at all. Then, you'd have to write either |
I think from a user perspective you'd expect |
I think we agree on the semantics. However, we'll implement this as |
Awesome, thank you. It's really nice to see all these usability improvements lately leading up to the next release. |
Using
caf::after
is dangerous: It permanently keeps a strong reference to the actor on its own clock, leading to an actor never shutting down because its handle's refcount going to zero.I propose adding a version of
caf::after
that holds a weak reference to the actor, or—which I would personally prefer—to make the breaking change of always holding a weak reference incaf::after
.CAF is currently designed in a way that actors should shut down when their refcount goes to zero. However, some mechanisms in CAF actively work against that, and as such are easy traps to fall into for new users especially.
The text was updated successfully, but these errors were encountered: