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.
38 39 40 41 |
# File 'lib/gouda/worker.rb', line 38 def initialize(seconds_float) @dt = seconds_float @st = Process.clock_gettime(Process::CLOCK_MONOTONIC) end |
Instance Method Details
#call ⇒ Object
43 44 45 |
# File 'lib/gouda/worker.rb', line 43 def call (Process.clock_gettime(Process::CLOCK_MONOTONIC) - @st) > @dt end |