Class: Qpid::Proton::Container::ListenTask
- Defined in:
- lib/core/container.rb
Instance Attribute Summary collapse
- #listener readonly
Attributes inherited from Listener
Instance Method Summary collapse
- #can_read? ⇒ Boolean
- #can_write? ⇒ Boolean
-
#close(e = nil)
Close listener and force immediate close of socket.
- #closed? ⇒ Boolean
- #closing? ⇒ Boolean
- #condition
- #dispatch(method, *args)
- #finished? ⇒ Boolean
-
#initialize(io, handler, container) ⇒ ListenTask
constructor
A new instance of ListenTask.
- #next_tick
- #process
Methods inherited from Listener
Constructor Details
#initialize(io, handler, container) ⇒ ListenTask
Returns a new instance of ListenTask.
277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/core/container.rb', line 277 def initialize(io, handler, container) @io, @handler = io, handler @listener = Listener.new(io, container) 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 Attribute Details
#listener (readonly)
289 290 291 |
# File 'lib/core/container.rb', line 289 def listener @listener end |
Instance Method Details
#can_read? ⇒ Boolean
313 |
# File 'lib/core/container.rb', line 313 def can_read?() !finished?; end |
#can_write? ⇒ Boolean
314 |
# File 'lib/core/container.rb', line 314 def can_write?() false; end |
#close(e = nil)
Close listener and force immediate close of socket
326 327 328 329 |
# File 'lib/core/container.rb', line 326 def close(e=nil) @listener.close(e) @io.close rescue nil end |
#closed? ⇒ Boolean
292 |
# File 'lib/core/container.rb', line 292 def closed?() @io.closed?; end |
#closing? ⇒ Boolean
290 |
# File 'lib/core/container.rb', line 290 def closing?() @listener.instance_variable_get(:@closing); end |
#condition
291 |
# File 'lib/core/container.rb', line 291 def condition() @listener.instance_variable_get(:@condition); end |
#dispatch(method, *args)
317 318 319 320 321 |
# File 'lib/core/container.rb', line 317 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
315 |
# File 'lib/core/container.rb', line 315 def finished?() closed?; end |
#next_tick
323 |
# File 'lib/core/container.rb', line 323 def next_tick() nil; end |
#process
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/core/container.rb', line 294 def process return if closed? unless closing? begin return @io.accept, dispatch(:on_accept) rescue IO::WaitReadable, Errno::EINTR rescue StandardError => e @listener.close(e) end end ensure if closing? @io.close rescue nil @listener.instance_variable_set(:@closed, true) dispatch(:on_error, condition) if condition dispatch(:on_close) end end |