Skip to content

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

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).

See also #io_pwrite #io_select #io_pread #io_wait also in 4.0 · 3.4 · 3.3 · 3.2