class Raft::Timer

Public Class Methods

new(interval, splay=0.0) click to toggle source
# File lib/raft.rb, line 148
def initialize(interval, splay=0.0)
  @interval = interval.to_f
  @splay = splay.to_f
  @start = Time.now - @interval + (rand * @splay)
end

Public Instance Methods

reset!() click to toggle source
# File lib/raft.rb, line 158
def reset!
  @start = Time.now + splayed_interval
  #STDOUT.write("\ntimer will elapse at #{timeout.strftime('%H:%M:%S:%L')} (timeout is #{timeout.class})\n")
end
splayed_interval() click to toggle source
# File lib/raft.rb, line 154
def splayed_interval
  (@interval + (rand * @splay))#.tap {|t|STDOUT.write("\nsplayed interval is #{t}\n")}
end
timed_out?() click to toggle source
# File lib/raft.rb, line 167
def timed_out?
  #STDOUT.write("\ntime is #{Time.now.strftime('%M:%S:%L')}\n")
  Time.now > timeout
end
timeout() click to toggle source
# File lib/raft.rb, line 163
def timeout
  @start + @interval
end