class Async::Debug::Selector
def close
def close if @monitors.any? raise LeakError, @monitors.values end ensure @selector.close end
def deregister(object)
def deregister(object) Async.logger.debug(self) {"Deregistering #{object.inspect}."} unless io = ::IO.try_convert(object) raise RuntimeError, "Could not convert #{io} into IO!" end unless @monitors.delete(io.fileno) raise RuntimeError, "Trying to remove monitor for #{io.inspect} but it was not registered!" end end
def initialize(selector = NIO::Selector.new)
def initialize(selector = NIO::Selector.new) @selector = selector @monitors = {} 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 if monitor = @monitors[io.fileno] raise RuntimeError, "Trying to register monitor for #{object.inspect} but it was already registered: #{monitor.inspect}!" end monitor = Monitor.new(@selector.register(object, interests), self) @monitors[io.fileno] = monitor return monitor end
def select(*args)
def select(*args) @selector.select(*args) end
def wakeup
def wakeup @selector.wakeup end