End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
Fiber::Scheduler#io_read
VALUE
rb_fiber_scheduler_io_read(VALUE scheduler, VALUE io, VALUE buffer, size_t length, size_t offset)
{
VALUE arguments[] = {
io, buffer, SIZET2NUM(length), SIZET2NUM(offset)
};
return rb_check_funcall(scheduler, id_io_read, 4, arguments);
}
Invoked by IO#read to read length bytes from io into a specified buffer (see IO::Buffer).
The length argument is the “minimum length to be read”. If the IO buffer size is 8KiB, but the length is 1024 (1KiB), up to 8KiB might be read, but at least 1KiB will be. Generally, the only case where less data than length will be read is if there is an error reading the data.
Specifying a length of 0 is valid and means try reading at least once and return any available data.
Suggested implementation should try to read from io in a non-blocking manner and call io_wait if the io is not ready (which will yield control to other fibers).
See IO::Buffer for an interface available to return data.
Expected to return number of bytes read, or, in case of an error, -errno (negated number corresponding to system’s error code).
The method should be considered experimental.