Created
December 8, 2012 15:28
-
-
Save godfat/4240745 to your computer and use it in GitHub Desktop.
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 'eventmachine' | |
require 'fiber' | |
def process | |
f = Fiber.current | |
EM.add_timer(2){ puts "Time's Up!"; f.resume } | |
Fiber.yield | |
puts "Process Done!" | |
EM.stop | |
end | |
EM.run{ | |
Fiber.new{ | |
# here i don't want to pass the fiber in, so Fiber.current would be useful | |
process | |
}.resume | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment