Created
November 26, 2013 08:50
-
-
Save jsaak/7655254 to your computer and use it in GitHub Desktop.
cooperative multitasking using Eventmachine Synchrony and Fibers
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 "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