Project

General

Profile

Feature #13821 » fiber_across_threads.rb

reproduction code - cremes (Chuck Remes), 08/16/2017 05:01 PM

 
queue = Queue.new

threadA = Thread.new do
fiber = Fiber.new do
puts "Created in ThreadA"
val = Fiber.yield
puts "Resumed in ThreadB with val #{val}"
end
fiber.resume
queue << fiber
end

threadB = Thread.new do
fiber = queue.pop
fiber.resume(3)
end

threadA.join
threadB.join

# Expect this output:
# Created in ThreadA
# Resumed in ThreadB with val 3

(1-1/2)