Class: EventMachine::Protocols::Zmq2::Dealer
- Inherits:
-
PreDealer
- Object
- Socket
- PreDealer
- EventMachine::Protocols::Zmq2::Dealer
show all
- Defined in:
- lib/em/protocols/zmq2/dealer.rb
Overview
ZMQ socket which tries to be a lot like a Dealer. It stores messages into outgoing queue, it tries to balance on socket busyness (which is slightely more, than ZMQ do). The only visible change from PreDealer is less frequent send_message
false return.
Instance Method Summary
collapse
Methods inherited from PreDealer
#choose_peer, #receive_message, #receive_message_and_peer
Constructor Details
#initialize(opts = {}) ⇒ Dealer
92
93
94
95
|
# File 'lib/em/protocols/zmq2/dealer.rb', line 92
def initialize(opts = {})
super
@write_queue = []
end
|
Instance Method Details
#flush_queue(even_if_busy = false) ⇒ Object
98
99
100
101
102
103
104
|
# File 'lib/em/protocols/zmq2/dealer.rb', line 98
def flush_queue(even_if_busy = false)
until @write_queue.empty?
return false unless raw_send_message(@write_queue.first, even_if_busy)
@write_queue.shift
end
true
end
|
#peer_free(peer_identity, connection) ⇒ Object
110
111
112
113
|
# File 'lib/em/protocols/zmq2/dealer.rb', line 110
def peer_free(peer_identity, connection)
super
flush_queue
end
|
#raw_send_message ⇒ Object
97
|
# File 'lib/em/protocols/zmq2/dealer.rb', line 97
alias raw_send_message send_message
|
#send_message(message) ⇒ Object
106
107
108
|
# File 'lib/em/protocols/zmq2/dealer.rb', line 106
def send_message(message)
flush_queue && super(message) || push_to_queue(@write_queue, message)
end
|