async-interop / event-loop

An event loop interface for interoperability in PHP.
MIT License
169 stars 9 forks source link

Specify when exactly a watchers callbacks may start to be called #78

Closed bwoebi closed 8 years ago

bwoebi commented 8 years ago

Delaying activation of watchers to the next tick guarantees consistent behavior between all implementations.

Additionally it eliminates the following problem:

If the answer is same tick, what happens in the following scenario:

We get similar problems with e.g. delay() and repeat() (if their timer all expired now, but we require order to be preserved).

Thus we need to pretty much delay the activation of enable() to the next tick to avoid potential ambiguity or different behaviors depending on when exactly the enable() or watcher registration happened.