tonarino / actor

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

Built-in timers/intervals #14

Closed mcginty closed 3 years ago

mcginty commented 3 years ago

Do we want??

strohel commented 3 years ago

Would this mean something more involved than thread::sleep()? Perhaps interruptible sleep, perhaps by the control channel/shutdown? (the interruptible sleep sounds a bit like async runtime though)

bschwind commented 3 years ago

I think it mostly means being able to run actors at a repeated interval (to rephrase, send them messages at a fixed interval), or send a message after a specified timeout without blocking any threads. Async runtimes would definitely be helpful here.

mcginty commented 3 years ago

Async runtimes basically just run a separate timer thread that usually uses the Timing Wheels architecture.

See: https://docs.rs/tokio-timer/0.2.13/tokio_timer/timer/struct.Timer.html

I guess it would be a matter of us deciding if we wanted to (possibly behind a feature flag) implement or import a timer thread that could send messages at delays or intervals.

bschwind commented 3 years ago

Some resources that will be helpful here:

https://github.com/tokio-rs/tokio/tree/master/tokio-util/src/time

https://crates.io/crates/hierarchical_hash_wheel_timer

https://crates.io/crates/delay_timer

bschwind commented 3 years ago

A simple, naive implementation has been implemented in #52 but I'd like to eventually replace that implementation with #53 after settling on a user-facing API.

strohel commented 3 years ago

53 has been merged, but per comments therein we still want to introduce a helper actor + an ergonomic API on top of it. I'll open a PR to iterate that.