igrigorik/em-synchrony — pull request #172 by dirkbolte (2013-10-22 10:14:42+00:00)
Title: added 'locked_periodic_timer' to prevent double execution

In the case mentioned in issue #170, I had to add code to prevent the same block from being executed multiple times when started via a periodic timer. In case that (e.g. due to connection timeouts) a block executed in a Fiber takes longer than the time specified in the timer, this might queue up and thereby impact further processing.
In my case, I use periodic timers for regular jobs for which is does not matter whether they are for sure executed every time the timer hits but they should be executed on a regular basis.
I ended up adding some kind of lock in multiple places. Adding this to EM::Synchrony would DRY this up. I hope this is useful for others as well.