Class: Transformer::SecondYielder

Inherits:
Consumer::Yielder show all
Defined in:
lib/coroutines/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(y, fiber) ⇒ SecondYielder

Returns a new instance of SecondYielder.



269
270
271
# File 'lib/coroutines/base.rb', line 269

def initialize(y, fiber)
	@y, @fiber = y, fiber
end

Instance Method Details

#awaitObject

Raises:

  • (StopIteration)


274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/coroutines/base.rb', line 274

def await
	raise StopIteration unless @fiber.alive?
	tag, result = @fiber.resume
	while tag == :await do
		x = nil
		begin
			x = @y.await
		rescue Exception => e
			tag, result = @fiber.raise(e)
		end
		tag, result = @fiber.resume(*x) unless x.nil?
		raise StopIteration unless @fiber.alive?
	end
	result
end

#yield(*args) ⇒ Object Also known as: <<



306
307
308
# File 'lib/coroutines/base.rb', line 306

def yield(*args)
	@y.yield(*args)
end