class Async::Wrapper
Represents an asynchronous IO within a reactor.
def close
def close @monitor.close if @monitor @monitor = nil end
def initialize(io, task)
def initialize(io, task) @io = io @task = task @monitor = nil end
def monitor(interests)
def monitor(interests) unless @monitor @monitor = @task.register(@io, interests) else @monitor.interests = interests end @monitor.value = Fiber.current yield ensure @monitor.value = nil if @monitor end
def wait_any(interests = :rw)
def wait_any(interests = :rw) monitor(interests) do Task.yield end end
def wait_readable
def wait_readable wait_any(:r) end
def wait_writable
def wait_writable wait_any(:w) end