instance method
Fiber::Scheduler#io_wait
io_wait(io, events, timeout)
scheduler.c
View on GitHub ↗
VALUE
rb_fiber_scheduler_io_wait(VALUE scheduler, VALUE io, VALUE events, VALUE timeout)
{
VALUE arguments[] = {
scheduler, io, events, timeout
};
if (rb_respond_to(scheduler, id_fiber_interrupt)) {
return rb_thread_io_blocking_operation(io, fiber_scheduler_io_wait, (VALUE)&arguments);
} else {
return fiber_scheduler_io_wait((VALUE)&arguments);
}
}
Invoked by IO#wait, IO#wait_readable, IO#wait_writable to ask whether the specified descriptor is ready for specified events within the specified timeout.
events is a bit mask of IO::READABLE, IO::WRITABLE, and IO::PRIORITY.
Suggested implementation should register which Fiber is waiting for which resources and immediately calling Fiber.yield to pass control to other fibers. Then, in the close method, the scheduler might dispatch all the I/O resources to fibers waiting for it.
Expected to return the subset of events that are ready immediately.