Class: ZK::ZKEventMachine::EventHandlerEM
- Inherits:
-
EventHandler
- Object
- EventHandler
- ZK::ZKEventMachine::EventHandlerEM
- Includes:
- Logging
- Defined in:
- lib/z_k/z_k_event_machine/event_handler_e_m.rb
Overview
a small wrapper around the EventHandler instance, allowing us to deliver the event on the reactor thread, as opposed to calling it directly
Instance Method Summary collapse
- #process(event) ⇒ Object
- #register(path, &block) ⇒ Object (also: #subscribe)
-
#synchronize ⇒ Object
protected
we’re running on the Reactor, don’t need to synchronize (hah, hah, we’ll see…).
Instance Method Details
#process(event) ⇒ Object
20 21 22 |
# File 'lib/z_k/z_k_event_machine/event_handler_e_m.rb', line 20 def process(event) EM.schedule { super(event) } end |
#register(path, &block) ⇒ Object Also known as: subscribe
9 10 11 12 13 14 15 16 17 |
# File 'lib/z_k/z_k_event_machine/event_handler_e_m.rb', line 9 def register(path, &block) # use the supplied block, but ensure that it gets called on the reactor # thread new_blk = lambda do |*a| EM.schedule { block.call(*a) } end super(path, &new_blk) end |
#synchronize ⇒ Object (protected)
we’re running on the Reactor, don’t need to synchronize (hah, hah, we’ll see…)
27 28 29 |
# File 'lib/z_k/z_k_event_machine/event_handler_e_m.rb', line 27 def synchronize yield end |