class Async::Scheduler

def io_read(io, buffer, length, offset = 0)

@parameter offset [Integer] The offset within the buffer to read into.
@parameter length [Integer] The minimum number of bytes to read.
@parameter buffer [IO::Buffer] The buffer to read into.
@parameter io [IO] The IO object to read from.

@asynchronous May be non-blocking.
@public Since *Async v2* and Ruby with `IO::Buffer` support.

Read from the specified IO into the buffer.
def io_read(io, buffer, length, offset = 0)
	fiber = Fiber.current
	
	if timeout = io.timeout
		timer = @timers.after(timeout) do
			fiber.raise(::IO::TimeoutError, "Timeout (#{timeout}s) while waiting for IO to become readable!")
		end
	end
	
	@selector.io_read(fiber, io, buffer, length, offset)
ensure
	timer&.cancel!
end