Skip to content

Instantly share code, notes, and snippets.

@genki
Created November 21, 2019 22:33
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 genki/3b2869ee9553c451facbd317c4cd48ca to your computer and use it in GitHub Desktop.
Save genki/3b2869ee9553c451facbd317c4cd48ca to your computer and use it in GitHub Desktop.
require "em-synchrony"
def foo
fiber = Fiber.current
EM::Timer.new 3 do
fiber.resume "foo"
end
Fiber.yield
end
EM.synchrony do
fiber = Fiber.current
EM.next_tick{fiber.resume "bar"}
puts foo #=> bar
Fiber.yield
EM.stop
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment