class Async::Debug::Selector
def close
def close if @monitors.any? raise LeakError, @monitors end ensure @selector.close end
def deregister(monitor)
def deregister(monitor) Async.logger.debug(self) {"Deregistering #{monitor.inspect}."} unless @monitors.delete?(monitor) raise RuntimeError, "Trying to remove monitor for #{monitor.inspect} but it was not registered!" end end
def initialize(selector = NIO::Selector.new)
def initialize(selector = NIO::Selector.new) @selector = selector @monitors = Set.new end
def register(object, interests)
def register(object, interests) Async.logger.debug(self) {"Registering #{object.inspect} for #{interests}."} unless io = ::IO.try_convert(object) raise RuntimeError, "Could not convert #{io} into IO!" end monitor = Monitor.new(@selector.register(object, interests), self) @monitors.add(monitor) return monitor end
def select(*arguments)
def select(*arguments) @selector.select(*arguments) end
def wakeup
def wakeup @selector.wakeup end