Sha256: cf011f34b55f9d167f689b61d72526ee01a415eb3cf92aef96b0fed5f44ad563
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
require 'net/protocol' class Net::BufferedIO def wait_io(interest) await(Promise.new do |resolve| io = @io.to_io EventLoop.register(io, interest) do EventLoop.deregister(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.2.0 | lib/midori/extension/net.rb |