Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Fiber::Scheduler#io_read
io_read(io, buffer, offset, length) → read length or -errno
scheduler.c
View on GitHub ↗
VALUE
rb_fiber_scheduler_io_read(VALUE scheduler, VALUE io, VALUE buffer, size_t offset, size_t length)
{
if (!rb_respond_to(scheduler, id_io_read)) {
return RUBY_Qundef;
}
VALUE arguments[] = {
scheduler, io, buffer, SIZET2NUM(offset), SIZET2NUM(length)
};
return rb_thread_io_blocking_operation(io, fiber_scheduler_io_read, (VALUE)&arguments);
}
Invoked by IO#read or IO::Buffer#read to perform one read of at most length bytes from io into a specified buffer (see IO::Buffer), starting at the given offset.
A short read is returned directly. Specifying a length of 0 returns 0 without performing a read.
The implementation should perform one non-blocking read and return -EAGAIN if io is not ready. The caller can then wait and retry as appropriate.
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).