Created
March 6, 2012 19:19
-
-
Save releu/1988392 to your computer and use it in GitHub Desktop.
test 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
process = Fiber.new do | |
i = 0 | |
loop do | |
puts "process_#{i = i.next}" | |
sleep 0.1 | |
Fiber.yield | |
end | |
end | |
loop do | |
if File.exists?('/Users/releu/pause') | |
sleep 0.1 | |
else | |
process.resume unless | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment