Sha256: e80712560393534e5995561d87b869bbd94dc855ecb422ad2ab927e3e7c81b7f
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
require 'net/protocol' class Net::BufferedIO def wait_io(interest) await(Promise.new do |resolve| EventLoop.register(@io.to_io, interest) do EventLoop.deregister(@io.to_io) resolve.call(self) end end) end def rbuf_fill loop do case rv = @io.read_nonblock(BUFSIZE, exception: false) when String return @rbuf << rv when :wait_readable wait_io(:r) # @io.to_io.wait_readable(@read_timeout) or raise Net::ReadTimeout # continue looping when :wait_writable # OpenSSL::Buffering#read_nonblock may fail with IO::WaitWritable. # http://www.openssl.org/support/faq.html#PROG10 # :nocov: wait_io(:w) # @io.to_io.wait_writable(@read_timeout) or raise Net::ReadTimeout # continue looping when nil # callers do not care about backtrace, so avoid allocating for it raise EOFError, 'end of file reached', [] # :nocov: end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
em-midori-0.1.12 | lib/midori/extension/net.rb |