Skip to content

Instantly share code, notes, and snippets.

@jsaak
Created December 3, 2013 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsaak/7767903 to your computer and use it in GitHub Desktop.
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)
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