Class: Binaryen::Command::TimeoutChecker
- Inherits:
-
Object
- Object
- Binaryen::Command::TimeoutChecker
- Defined in:
- lib/binaryen/command.rb
Instance Method Summary collapse
- #check! ⇒ Object
-
#initialize(end_time:, pid:) ⇒ TimeoutChecker
constructor
A new instance of TimeoutChecker.
Constructor Details
#initialize(end_time:, pid:) ⇒ TimeoutChecker
Returns a new instance of TimeoutChecker.
25 26 27 28 |
# File 'lib/binaryen/command.rb', line 25 def initialize(end_time:, pid:) @end_time = end_time @pid = pid end |
Instance Method Details
#check! ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/binaryen/command.rb', line 30 def check! now = Process.clock_gettime(Process::CLOCK_MONOTONIC) if now >= @end_time Process.kill("KILL", @pid) raise Timeout::Error, "Command timed out" end remaining_time = @end_time - now remaining_time end |