lib/pitchfork/worker.rb in pitchfork-0.4.1 vs lib/pitchfork/worker.rb in pitchfork-0.5.0

- old
+ new

@@ -91,11 +91,11 @@ def promoted! @mold = true @nr = nil @drop_offset = 0 - @tick_drop = MOLD_DROP + @deadline_drop = MOLD_DROP self end def mold? @mold @@ -165,25 +165,29 @@ # worker objects may be compared to just plain Integers def ==(other) # :nodoc: super || (!@nr.nil? && @nr == other) end + def update_deadline(timeout) + self.deadline = Pitchfork.time_now(true) + timeout + end + # called in the worker process - def tick=(value) # :nodoc: + def deadline=(value) # :nodoc: if mold? MOLD_DROP[0] = value else - @tick_drop[@drop_offset] = value + @deadline_drop[@drop_offset] = value end end # called in the master process - def tick # :nodoc: + def deadline # :nodoc: if mold? MOLD_DROP[0] else - @tick_drop[@drop_offset] + @deadline_drop[@drop_offset] end end def reset @requests_count = 0 @@ -219,11 +223,11 @@ case @master.sendmsg_nonblock(message, exception: false) when :wait_writable else success = true end - rescue Errno::EPIPE, Errno::ECONNRESET + rescue Errno::EPIPE, Errno::ECONNRESET, Errno::ECONNREFUSED # worker will be reaped soon end success end @@ -246,10 +250,10 @@ end def build_raindrops(drop_nr) drop_index = drop_nr / PER_DROP @drop_offset = drop_nr % PER_DROP - @tick_drop = TICK_DROPS[drop_index] ||= Raindrops.new(PER_DROP) - @tick_drop[@drop_offset] = 0 + @deadline_drop = TICK_DROPS[drop_index] ||= Raindrops.new(PER_DROP) + @deadline_drop[@drop_offset] = 0 end end end