Concurrency Coordination Reports
Fiber Resume Coordination Report
Resume a fiber to read the checkpoint it reports and label the reached stage.
Fiber Resume Coordination Report
fiber_resume_coordination_report.rb
checkpoint =
labels = ["first", "second", "done"]
sequence = Fiber.new do
Fiber.yield(labels.fetch(checkpoint - 1))
"closed"
end
reached = sequence.resume
alive = sequence.alive?
status = reached
puts "checkpoint=#{checkpoint}"
puts "reached=#{reached}"
puts "alive=#{alive}"
puts "status=#{status}"
checkpoint =
labels = ["first", "second", "done"]
sequence = Fiber.new do
Fiber.yield(labels.fetch(checkpoint - 1))
"closed"
end
reached = sequence.resume
alive = sequence.alive?
status = reached
puts "checkpoint=#{checkpoint}"
puts "reached=#{reached}"
puts "alive=#{alive}"
puts "status=#{status}"
checkpoint =
labels = ["first", "second", "done"]
sequence = Fiber.new do
Fiber.yield(labels.fetch(checkpoint - 1))
"closed"
end
reached = sequence.resume
alive = sequence.alive?
status = reached
puts "checkpoint=#{checkpoint}"
puts "reached=#{reached}"
puts "alive=#{alive}"
puts "status=#{status}"
fiber resume
`Fiber#resume` runs a fiber until its `Fiber.yield` and returns the yielded value, so resuming the fiber reads the checkpoint it reports for the selected stage while the fiber stays suspended and no background work keeps running.