Created
May 29, 2014 05:02
-
-
Save scalone/23f39caf2f7e8917795e to your computer and use it in GitHub Desktop.
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
fib = Fiber.new do | |
x, y = 0, 1 | |
loop do | |
puts "before stop" | |
Fiber.yield y | |
puts "after stop" | |
x,y = y,x+y | |
end | |
end | |
#20.times { puts fib.resume } | |
class T | |
def initialize() | |
end | |
def execute | |
[:print, :key_read, :print].each do |m| | |
self.send m | |
end | |
end | |
def print | |
puts "print" | |
end | |
def key_read | |
@fib = Fiber.new do | |
key = "enter" | |
Fiber.yield key | |
end | |
end | |
end | |
run_time = Fiber do | |
T.new.execute | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment