Class: Qpid::Proton::HandlerDriver
- Inherits:
-
ConnectionDriver
- Object
- ConnectionDriver
- Qpid::Proton::HandlerDriver
- Defined in:
- lib/core/connection_driver.rb
Overview
A ConnectionDriver that feeds raw proton events to a handler.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#handler ⇒ MessagingHandler
readonly
The handler dispatched to by #process.
Attributes inherited from ConnectionDriver
Instance Method Summary collapse
-
#dispatch
Dispatch all available raw proton events from ConnectionDriver#event to #handler.
-
#initialize(io, handler) ⇒ HandlerDriver
constructor
Combine an IO with a handler and provide a simplified way to run the driver via #process.
-
#process(now = Time.now) ⇒ Time
Do ConnectionDriver#read, ConnectionDriver#tick, ConnectionDriver#write and #dispatch without blocking.
Methods inherited from ConnectionDriver
#can_read?, #can_write?, #close, #close_read, #close_write, #connection, #each_event, #event, #event?, #finished?, #read, #read_closed?, #tick, #to_io, #transport, #write, #write_closed?
Constructor Details
#initialize(io, handler) ⇒ HandlerDriver
Combine an IO with a handler and provide a simplified way to run the driver via #process
177 178 179 180 181 |
# File 'lib/core/connection_driver.rb', line 177 def initialize(io, handler) super(io) @handler = handler @adapter = Handler::Adapter.adapt(handler) end |
Instance Attribute Details
#handler ⇒ MessagingHandler (readonly)
Returns The handler dispatched to by #process.
184 185 186 |
# File 'lib/core/connection_driver.rb', line 184 def handler @handler end |
Instance Method Details
#dispatch
Dispatch all available raw proton events from ConnectionDriver#event to #handler
187 188 189 190 191 192 193 194 195 196 |
# File 'lib/core/connection_driver.rb', line 187 def dispatch() each_event do |e| case e.method # Events that affect the driver when :on_transport_tail_closed then close_read when :on_transport_head_closed then close_write when :on_transport_closed then @io.close rescue nil # Allow double-close end e.dispatch @adapter end end |
#process(now = Time.now) ⇒ Time
Do ConnectionDriver#read, ConnectionDriver#tick, ConnectionDriver#write and #dispatch without blocking.
202 203 204 205 206 207 208 209 210 |
# File 'lib/core/connection_driver.rb', line 202 def process(now=Time.now) read dispatch next_tick = tick(now) dispatch write dispatch return next_tick end |