End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
Fiber.blocking?
Fiber.blocking? → false or number
cont.c
View on GitHub ↗
static VALUE
rb_f_fiber_blocking_p(VALUE klass)
{
rb_thread_t *thread = GET_THREAD();
unsigned blocking = thread->blocking;
if (blocking == 0)
return Qfalse;
return INT2NUM(blocking);
}
Returns false if the current fiber is non-blocking. Fiber is non-blocking if it was created via passing blocking: false to Fiber.new, or via Fiber.schedule.
If the current Fiber is blocking, the method, unlike usual predicate methods, returns a number of blocking fibers currently running (TBD: always 1?).
Note, that even if the method returns false, Fiber behaves differently only if Fiber.scheduler is set in the current thread.
See the “Non-blocking fibers” section in class docs for details.
Ruby version changes
-
3.0
-
Fiber.blocking?tells whether the current execution context is blocking. [Feature #16786]
-