You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, event-based actors automatically "stash" messages if users skip them in a default handler. Stashing basically means: a skipped message gets put into a stash until an incoming message matched the behavior. Then, all messages from the stash get put back into the mailbox and re-matched again for the next run.
There are some use cases where this work flow makes sense, but all actors have this stash, even if they never use it. It's also easy to shoot yourself in the foot with this implicit skipping, because the constant re-scanning can become expensive. Instead of doing this implicitly, we should instead:
Provide an explicit caf::stash class to allow actors that actually need this feature to use it manually.
Deprecate skippable_result as well as the default handler in general (set_default_handler) and remove with version 1.0. Event-based actors that receive unexpected inputs should terminate.
If users want to deal with unexpected inputs in any other way (like stashing): we should bring back "catch-all" handlers for event-based actors. We don't need to have a special syntax for this, I think. A handler with signature [](message msg) { } (or any cv-qualified version thereof) could be treated as catch-all.
Maybe we can also use this opportunity to get rid of the other special handlers as well. Issue #1423 already suggests using an alternative approach for down messages. Basically just remove the old way instead of "overloading" it. We could get rid of the exit handler as well: just add a [](const exit_msg&) handler to your behavior if you want to "override" the default behavior. In my experience, actors that override the exit handler very rarely switch behaviors. The original idea of separating the exit handlers from the behavior was to allow actors to have "constant" exit handler with changing behaviors, but several years later, I think that's just a non-issue. By going down this route, we could get rid of all of these member variables:
I think it's also an easier mental model to have (and teach). There's the behavior of an actor that has your message callbacks. If an actors fails to match a message, it panicks (i.e., terminates). Period. Currently, it's: "The behavior has your message callbacks, but then there are these 5 special cases where CAF treats messages differently."
The text was updated successfully, but these errors were encountered:
Currently, event-based actors automatically "stash" messages if users skip them in a default handler. Stashing basically means: a skipped message gets put into a stash until an incoming message matched the behavior. Then, all messages from the stash get put back into the mailbox and re-matched again for the next run.
There are some use cases where this work flow makes sense, but all actors have this stash, even if they never use it. It's also easy to shoot yourself in the foot with this implicit skipping, because the constant re-scanning can become expensive. Instead of doing this implicitly, we should instead:
caf::stash
class to allow actors that actually need this feature to use it manually.skippable_result
as well as the default handler in general (set_default_handler
) and remove with version 1.0. Event-based actors that receive unexpected inputs should terminate.[](message msg) { }
(or any cv-qualified version thereof) could be treated as catch-all.Maybe we can also use this opportunity to get rid of the other special handlers as well. Issue #1423 already suggests using an alternative approach for down messages. Basically just remove the old way instead of "overloading" it. We could get rid of the
exit
handler as well: just add a[](const exit_msg&)
handler to your behavior if you want to "override" the default behavior. In my experience, actors that override the exit handler very rarely switch behaviors. The original idea of separating the exit handlers from the behavior was to allow actors to have "constant" exit handler with changing behaviors, but several years later, I think that's just a non-issue. By going down this route, we could get rid of all of these member variables:I think it's also an easier mental model to have (and teach). There's the
behavior
of an actor that has your message callbacks. If an actors fails to match a message, it panicks (i.e., terminates). Period. Currently, it's: "Thebehavior
has your message callbacks, but then there are these 5 special cases where CAF treats messages differently."The text was updated successfully, but these errors were encountered: