Class: Passthrough
- Inherits:
-
Object
- Object
- Passthrough
- Includes:
- Messenger
- Defined in:
- lib/socketeer/passthrough.rb
Instance Attribute Summary
Attributes included from Messenger
Instance Method Summary collapse
- #cycle ⇒ Object
- #cycle_in_queue ⇒ Object
- #cycle_messenger ⇒ Object
- #cycle_out_queue ⇒ Object
-
#initialize(attr, messenger) ⇒ Passthrough
constructor
A new instance of Passthrough.
Methods included from Messenger
Constructor Details
#initialize(attr, messenger) ⇒ Passthrough
Returns a new instance of Passthrough.
7 8 9 10 11 12 |
# File 'lib/socketeer/passthrough.rb', line 7 def initialize attr, messenger @attr = attr @messenger = messenger @in_flight = [] bind_queues Queue.new, Queue.new end |
Instance Method Details
#cycle ⇒ Object
14 15 16 17 18 |
# File 'lib/socketeer/passthrough.rb', line 14 def cycle cycle_in_queue cycle_out_queue cycle_messenger end |
#cycle_in_queue ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/socketeer/passthrough.rb', line 20 def cycle_in_queue begin = in_queue.deq true if @in_flight << @messenger.in_queue << [@attr] end rescue ThreadError end end |
#cycle_messenger ⇒ Object
43 44 45 |
# File 'lib/socketeer/passthrough.rb', line 43 def cycle_messenger @messenger.cycle if @messenger.respond_to? 'cycle' end |
#cycle_out_queue ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/socketeer/passthrough.rb', line 31 def cycle_out_queue begin = @messenger.out_queue.deq true if = @in_flight.shift [@attr] = out_queue << end rescue ThreadError end end |