socketry/timers

Equivalent for EventMachine's #next_tick timer

Closed this issue · 1 comments

More of a question than an issue - apologies if this is not the right place to raise.

Some time ago I wrote a library (https://github.com/lwoggardner/empathy) to create Thread compatible primitives (Mutex, ConditionVariable, Queue) for the EventMachine reactor.

The idea was that this would mean that a library that used these constructs could easily be used with EventMachine (eg a simple Actor framework based on a Queue)

I'm toying with experimenting with porting that across to the socketry/async reactor, which is based on these timers. However the whole thing hangs on the concept of #next_tick - ie a one-shot timer that fires on the next iteration of the event loop.

Before I get too far down this path, I wanted to check if you think passing zero to Timers::Group#after would be the equivalent of next_tick. Thanks.

after(0) works, however if you'd like to fire all current timers and run something immediately after you can use #fire instead to immediately fire all pending timers, then run whatever you'd like to happen after the timers fire.