Class: Gouda::TimerShutdownCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/gouda/worker.rb

Overview

Returns ‘true` once a given timer has elapsed. This is useful to terminate a worker after a certain amount of time

Instance Method Summary collapse

Constructor Details

#initialize(seconds_float) ⇒ TimerShutdownCheck

Returns a new instance of TimerShutdownCheck.



37
38
39
40
# File 'lib/gouda/worker.rb', line 37

def initialize(seconds_float)
  @dt = seconds_float
  @st = Process.clock_gettime(Process::CLOCK_MONOTONIC)
end

Instance Method Details

#callObject



42
43
44
# File 'lib/gouda/worker.rb', line 42

def call
  (Process.clock_gettime(Process::CLOCK_MONOTONIC) - @st) > @dt
end