Skip to content

Instantly share code, notes, and snippets.

@jsaak
Created November 26, 2013 08:50
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 jsaak/7655254 to your computer and use it in GitHub Desktop.
Save jsaak/7655254 to your computer and use it in GitHub Desktop.
cooperative multitasking using Eventmachine Synchrony and Fibers
require "em-synchrony"
EventMachine.synchrony do
Fiber.new do
while true
EM::Synchrony.sleep(0.5)
puts 'here'
end
end.resume
Fiber.new do
while true
EM::Synchrony.sleep(0.9)
puts 'there'
end
end.resume
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment