lib/lightio/library/io.rb in lightio-0.2.0 vs lib/lightio/library/io.rb in lightio-0.2.1

- old
+ new

@@ -1,9 +1,9 @@ require 'forwardable' module LightIO::Library class IO - include LightIO::Wrap::Wrapper + include LightIO::Wrap::IOWrapper wrap ::IO extend Forwardable def_delegators :@io_watcher, :wait, :wait_readable, :wait_writable @@ -29,9 +29,19 @@ def readpartial(maxlen, outbuf=nil) (outbuf ||= "").clear outbuf << wait_nonblock(:read_nonblock, maxlen, exception_symbol: false) outbuf + end + + def close(*args) + # close watcher before io closed + @io_watcher&.close + @io.close(*args) + end + + def to_io + self end class << self def open(*args) io = self.new(*args)