AsyncSourceAsyncWrapper

class Wrapper

Represents an asynchronous IO within a reactor.

Signature

deprecated

With no replacement. Prefer native interfaces.

Nested

Definitions

def initialize(io, reactor = nil)

Signature

parameter reactor Reactor

the reactor that is managing this wrapper, or not specified, it's looked up by way of Async::Task.current.

Implementation

def initialize(io, reactor = nil)
	@io = io
	@reactor = reactor
	
	@timeout = nil
end

def dup

Dup the underlying IO.

Implementation

def dup
	self.class.new(@io.dup)
end

attr :io

The underlying native io.

def wait_readable(timeout = @timeout)

Wait for the io to become readable.

Implementation

def wait_readable(timeout = @timeout)
	@io.to_io.wait_readable(timeout) or raise TimeoutError
end

def wait_priority(timeout = @timeout)

Wait for the io to become writable.

Implementation

def wait_priority(timeout = @timeout)
	@io.to_io.wait_priority(timeout) or raise TimeoutError
end

def wait_writable(timeout = @timeout)

Wait for the io to become writable.

Implementation

def wait_writable(timeout = @timeout)
	@io.to_io.wait_writable(timeout) or raise TimeoutError
end

def wait_any(timeout = @timeout)

Wait fo the io to become either readable or writable.

Signature

parameter duration Float

timeout after the given duration if not nil.

Implementation

def wait_any(timeout = @timeout)
	@io.to_io.wait(::IO::READABLE|::IO::WRITABLE|::IO::PRIORITY, timeout) or raise TimeoutError
end

def close

Close the underlying IO.

Implementation

def close
	@io.close
end

def closed?

Whether the underlying IO is closed.

Implementation

def closed?
	@io.closed?
end

Discussion