Created
October 23, 2011 16:43
-
-
Save grantr/1307568 to your computer and use it in GitHub Desktop.
naive timers in celluloid
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
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