tonarino / actor

A minimalist actor framework aiming for high performance and simplicity.
MIT License
40 stars 6 forks source link

Add Timed actor wrapper + friends for delayed/recurring messages #58

Closed strohel closed 2 years ago

strohel commented 2 years ago

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:

  1. in actor (thread) A
  2. in some separate actor (thread) C
  3. 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:

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.

strohel commented 2 years ago

Thanks for the reviews!

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