lib/zmachine/hashed_wheel.rb in zmachine-0.3.0 vs lib/zmachine/hashed_wheel.rb in zmachine-0.3.2

- old
+ new

@@ -33,13 +33,13 @@ end def add(timeout, &block) timeout *= 1_000_000_000 # s to ns ticks = timeout / @tick_length - slot = (@current_tick + ticks) % @slots.length - HashedWheelTimeout.new(System.nano_time + timeout, &block).tap do |hwt| - @slots[slot] << hwt - end + slot = (@current_tick + ticks) % @slots.length + deadline = System.nano_time + timeout + @slots[slot] << hwt = HashedWheelTimeout.new(deadline, &block) + hwt end def reset(time = nil) @slots = Array.new(@slots.length) { [] } @current_tick = 0