Class: Gouda::TimerShutdownCheck
- Inherits:
-
Object
- Object
- Gouda::TimerShutdownCheck
- 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
- #call ⇒ Object
-
#initialize(seconds_float) ⇒ TimerShutdownCheck
constructor
A new instance of TimerShutdownCheck.
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
#call ⇒ Object
42 43 44 |
# File 'lib/gouda/worker.rb', line 42 def call (Process.clock_gettime(Process::CLOCK_MONOTONIC) - @st) > @dt end |