Class: OMQ::Routing::Gather
- Inherits:
-
Object
- Object
- OMQ::Routing::Gather
- Defined in:
- lib/omq/routing/gather.rb
Overview
GATHER socket routing: fair-queue receive from SCATTER peers.
Instance Attribute Summary collapse
- #recv_queue ⇒ Async::LimitedQueue readonly
Instance Method Summary collapse
- #connection_added(connection) ⇒ Object
- #connection_removed(connection) ⇒ Object
-
#dequeue_recv ⇒ Array<String>?
Dequeues the next received message.
-
#enqueue(_parts) ⇒ Object
GATHER is read-only.
-
#initialize(engine) ⇒ Gather
constructor
A new instance of Gather.
-
#stop ⇒ Object
Stops all background tasks.
-
#unblock_recv ⇒ void
Wakes a blocked #dequeue_recv with a nil sentinel.
Constructor Details
Instance Attribute Details
#recv_queue ⇒ Async::LimitedQueue (readonly)
19 20 21 |
# File 'lib/omq/routing/gather.rb', line 19 def recv_queue @recv_queue end |
Instance Method Details
#connection_added(connection) ⇒ Object
42 43 44 45 |
# File 'lib/omq/routing/gather.rb', line 42 def connection_added(connection) task = @engine.start_recv_pump(connection, @recv_queue) @tasks << task if task end |
#connection_removed(connection) ⇒ Object
50 51 |
# File 'lib/omq/routing/gather.rb', line 50 def connection_removed(connection) end |
#dequeue_recv ⇒ Array<String>?
Dequeues the next received message. Blocks until one is available.
26 27 28 |
# File 'lib/omq/routing/gather.rb', line 26 def dequeue_recv @recv_queue.dequeue end |
#enqueue(_parts) ⇒ Object
GATHER is read-only.
56 57 58 |
# File 'lib/omq/routing/gather.rb', line 56 def enqueue(_parts) raise "GATHER sockets cannot send" end |
#stop ⇒ Object
Stops all background tasks.
62 63 64 65 |
# File 'lib/omq/routing/gather.rb', line 62 def stop @tasks.each(&:stop) @tasks.clear end |
#unblock_recv ⇒ void
This method returns an undefined value.
Wakes a blocked #dequeue_recv with a nil sentinel.
35 36 37 |
# File 'lib/omq/routing/gather.rb', line 35 def unblock_recv @recv_queue.enqueue(nil) end |