See module level docs and delay_actor.rs example for info.
When actor A wants to send a delayed message to actor B, there are 3 places where the queue can be:
in actor (thread) A
in some separate actor (thread) C
in actor (thread) B.
This PR choses option 3. In our downstream usage, all recurring messages are "to self", so options 1. and 3. are functionally (but not API-wise) equivalent. The chosen approach has some pros and cons:
pro: modulo the preparatory "independent" core API changes, Timed<> wrapper and friends are strictly separate form the core API (could have been implemented in a separate crate).
pro: avoids having to pass some DelayActor reference around, or having it registered as some global resource.
pro: delayed messages do not cross thread boundary (in our use-case).
big con: requires wrapping each delayed-message-receiving actor in the wrapper.
con: requires ability to customize the Context type in actor as a prerequisite.
Closes #14.
Separated into atomic commits, reviewing them individually is suggested. The last commit adds the main functionality, others are prerequisites. I had to tweak core actor API a bit (with changes needing to be done downstream) to be able to provide a nice API of the delayed/recurring functionality.
I'll let this simmer down for a couple of days (if @bschwind or @skywhale want to give this another read), then I'd like to merge and cut a 0.6.0 release
See module level docs and
delay_actor.rs
example for info.When actor A wants to send a delayed message to actor B, there are 3 places where the queue can be:
This PR choses option 3. In our downstream usage, all recurring messages are "to self", so options 1. and 3. are functionally (but not API-wise) equivalent. The chosen approach has some pros and cons:
DelayActor
reference around, or having it registered as some global resource.Context
type in actor as a prerequisite.Closes #14.
Separated into atomic commits, reviewing them individually is suggested. The last commit adds the main functionality, others are prerequisites. I had to tweak core actor API a bit (with changes needing to be done downstream) to be able to provide a nice API of the delayed/recurring functionality.
Demonstration of downstream code changes tonarino/portal#1126, specifically https://github.com/tonarino/portal/pull/1126/commits/4cfefdd45ba2ff7155c6e1943ba90d1bc20c6fe0.