Created
December 3, 2013 11:49
-
-
Save jsaak/7767903 to your computer and use it in GitHub Desktop.
modify periodic timer frequency at runtime (works with EventMachine and EventMachine::Synchrony too)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "em-synchrony" | |
EventMachine.synchrony do | |
counter = 0 | |
timer = EM::Synchrony.add_periodic_timer(0.2) do | |
puts counter | |
counter += 1 | |
if counter > 4 | |
timer.interval = 1 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment