Skip to content

Instantly share code, notes, and snippets.

@grantr
Created October 23, 2011 16:43
Show Gist options
  • Save grantr/1307568 to your computer and use it in GitHub Desktop.
Save grantr/1307568 to your computer and use it in GitHub Desktop.
naive timers in celluloid
module Celluloid
class OneShotTimer
include Celluloid
def initialize(timeout)
@timeout = timeout
end
def fire
puts "fired"
end
def start
sleep @timeout
fire!
end
end
class IntervalTimer < OneShotTimer
def start
while alive?
super
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment