End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
Fiber.blocking?
Fiber.blocking? → false or 1
cont.c
View on GitHub ↗
static VALUE
rb_fiber_s_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 returns 1. Future developments may allow for situations where larger integers could be returned.
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]
-