Class: RGossip::Gossiper
- Inherits:
-
Object
- Object
- RGossip::Gossiper
- Defined in:
- lib/rgossip/gossipper.rb
Constant Summary collapse
- @@interval =
0.1
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(my_node, node_list) ⇒ Gossiper
constructor
A new instance of Gossiper.
- #join ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(my_node, node_list) ⇒ Gossiper
Returns a new instance of Gossiper.
7 8 9 10 |
# File 'lib/rgossip/gossipper.rb', line 7 def initialize(my_node, node_list) @my_node = my_node @node_list = node_list end |
Class Method Details
.interval ⇒ Object
4 |
# File 'lib/rgossip/gossipper.rb', line 4 def self.interval; @@interval; end |
.interval=(v) ⇒ Object
5 |
# File 'lib/rgossip/gossipper.rb', line 5 def self.interval=(v); @@interval = v; end |
Instance Method Details
#join ⇒ Object
42 43 44 |
# File 'lib/rgossip/gossipper.rb', line 42 def join @thread.join end |
#start ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rgossip/gossipper.rb', line 12 def start RGossip.log("Start Gossiper: interval=#{@@interval}") @running = true @thread = Thread.start { begin sock = UDPSocket.open while @running begin @node_list.synchronize { gossip(sock) } rescue Exception => e raise e unless RGossip.error_handler RGossip.error_handler.call(e) end sleep(@@interval) end ensure sock.close end } end |