Class: Qpid::Proton::Container::ListenTask
- Defined in:
- lib/core/container.rb
Instance Attribute Summary
Attributes inherited from Listener
Instance Method Summary collapse
- #can_read? ⇒ Boolean
- #can_write? ⇒ Boolean
- #dispatch(method, *args) ⇒ Object
- #finished? ⇒ Boolean
-
#initialize(io, handler, container) ⇒ ListenTask
constructor
A new instance of ListenTask.
- #process ⇒ Object
Methods inherited from Listener
Constructor Details
#initialize(io, handler, container) ⇒ ListenTask
Returns a new instance of ListenTask.
46 47 48 49 50 51 52 53 54 55 56 |
# 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 |
Instance Method Details
#can_read? ⇒ Boolean
77 |
# File 'lib/core/container.rb', line 77 def can_read?() !finished?; end |
#can_write? ⇒ Boolean
78 |
# File 'lib/core/container.rb', line 78 def can_write?() false; end |
#dispatch(method, *args) ⇒ Object
81 82 83 84 85 |
# 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 |
#finished? ⇒ Boolean
79 |
# File 'lib/core/container.rb', line 79 def finished?() @closed; end |
#process ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# 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 |