Class: RGossip::Receiver
- Inherits:
-
Object
- Object
- RGossip::Receiver
- Defined in:
- lib/rgossip/receiver.rb
Constant Summary collapse
- @@timeout =
3
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(my_node, node_list, dead_list, callback = nil) ⇒ Receiver
constructor
A new instance of Receiver.
- #join ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(my_node, node_list, dead_list, callback = nil) ⇒ Receiver
Returns a new instance of Receiver.
9 10 11 12 13 14 |
# File 'lib/rgossip/receiver.rb', line 9 def initialize(my_node, node_list, dead_list, callback = nil) @my_node = my_node @node_list = node_list @dead_list = dead_list @callback = callback end |
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback.
7 8 9 |
# File 'lib/rgossip/receiver.rb', line 7 def callback @callback end |
Class Method Details
.timeout ⇒ Object
4 |
# File 'lib/rgossip/receiver.rb', line 4 def self.timeout; @@timeout; end |
.timeout=(v) ⇒ Object
5 |
# File 'lib/rgossip/receiver.rb', line 5 def self.timeout=(v); @@timeout = v; end |
Instance Method Details
#join ⇒ Object
40 41 42 |
# File 'lib/rgossip/receiver.rb', line 40 def join @thread.join end |
#start ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rgossip/receiver.rb', line 16 def start RGossip.log("Start Receiver: port=#{RGossip.port}") @running = true @thread = Thread.start { begin sock = UDPSocket.open sock.bind(@my_node.address, RGossip.port) while @running receive(sock) end ensure sock.close end } end |