End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
Fiber.set_scheduler
static VALUE
rb_fiber_set_scheduler(VALUE klass, VALUE scheduler)
{
// if (rb_scheduler_get() != Qnil) {
// rb_raise(rb_eFiberError, "Scheduler is already defined!");
// }
return rb_scheduler_set(scheduler);
}
Sets Fiber scheduler for the current thread. If the scheduler is set, non-blocking fibers (created by Fiber.new with blocking: false, or by Fiber.schedule) call that scheduler’s hook methods on potentially blocking operations, and the current thread will call scheduler’s close method on finalization (allowing the scheduler to properly manage all non-finished fibers).
scheduler can be an object of any class corresponding to Fiber::SchedulerInterface. Its implementation is up to the user.
See also the “Non-blocking fibers” section in class docs.
Ruby version changes
-
3.0
-
Introduce
Fiber.set_schedulerfor intercepting blocking operations andFiber.schedulerfor accessing the current scheduler. See fiber.md for more details about what operations are supported and how to implement the scheduler hooks. [Feature #16786]
-