# File lib/core/container.rb, line 46 def initialize(io, handler, container) super @closing = @closed = nil env = ENV['PN_TRACE_EVT'] if env && ["true", "1", "yes", "on"].include?(env.downcase) @log_prefix = "[0x#{object_id.to_s(16)}](PN_LISTENER_" else @log_prefix = nil end dispatch(:on_open); end
# File lib/core/container.rb, line 77 def can_read?() !finished?; end
# File lib/core/container.rb, line 78 def can_write?() false; end
# File lib/core/container.rb, line 81 def dispatch(method, *args) # TODO aconway 2017-11-27: better logging STDERR.puts "#{@log_prefix}#{([method[3..-1].upcase]+args).join ', '})" if @log_prefix @handler.__send__(method, self, *args) if @handler && @handler.respond_to?(method) end
# File lib/core/container.rb, line 79 def finished?() @closed; end
# File lib/core/container.rb, line 58 def process return if @closed unless @closing begin return @io.accept, dispatch(:on_accept) rescue IO::WaitReadable, Errno::EINTR rescue IOError, SystemCallError => e close e end end ensure if @closing @io.close rescue nil @closed = true dispatch(:on_error, @condition) if @condition dispatch(:on_close) end end