Skip to content

Instantly share code, notes, and snippets.

@godfat
Created December 8, 2012 15:28
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 godfat/4240745 to your computer and use it in GitHub Desktop.
Save godfat/4240745 to your computer and use it in GitHub Desktop.
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