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.
21 22 23 24 |
# File 'lib/binaryen/command.rb', line 21 def initialize(end_time:, pid:) @end_time = end_time @pid = pid end |
Instance Method Details
#check! ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/binaryen/command.rb', line 26 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 |