# File lib/moqueue/fibers18.rb, line 47 47: def self.current 48: Thread.current[:fiber] or raise FiberError, 'not inside a fiber' 49: end
# File lib/moqueue/fibers18.rb, line 8 8: def initialize 9: raise ArgumentError, 'new Fiber requires a block' unless block_given? 10: 11: @yield = Queue.new 12: @resume = Queue.new 13: 14: @thread = Thread.new{ @yield.push [ *yield(*@resume.pop) ] } 15: @thread.abort_on_exception = true 16: @thread[:fiber] = self 17: end
# File lib/moqueue/fibers18.rb, line 20 20: def alive? 21: @thread.alive? 22: end
# File lib/moqueue/fibers18.rb, line 51 51: def inspect 52: "#<#{self.class}:0x#{self.object_id.to_s(16)}>" 53: end
# File lib/moqueue/fibers18.rb, line 24 24: def resume *args 25: raise FiberError, 'dead fiber called' unless @thread.alive? 26: raise FiberError, 'double resume' if @thread == Thread.current 27: @resume.push(args) 28: result = @yield.pop 29: result.size > 1 ? result : result.first 30: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.