mirror of
https://github.com/rubyjs/mini_racer
synced 2023-03-27 23:21:28 -04:00
simplify timeout implementation
Merely closing the pipe is enough to trigger a wakeup from IO#wait_readable, there's no need to make a write(2) syscall nor copy data in/out of the kernel. We'll use the Ruby 2.3+ 'foo&.method' calls in a few places to simplify code, as well.
This commit is contained in:
parent
5266fec597
commit
bdb0977d81
1 changed files with 4 additions and 7 deletions
|
@ -367,7 +367,7 @@ module MiniRacer
|
||||||
done = true
|
done = true
|
||||||
end
|
end
|
||||||
|
|
||||||
wp.write("done")
|
wp.close
|
||||||
|
|
||||||
# ensure we do not leak a thread in state
|
# ensure we do not leak a thread in state
|
||||||
t.join
|
t.join
|
||||||
|
@ -376,12 +376,9 @@ module MiniRacer
|
||||||
rval
|
rval
|
||||||
ensure
|
ensure
|
||||||
# exceptions need to be handled
|
# exceptions need to be handled
|
||||||
if t && wp
|
wp&.close
|
||||||
wp.write("done")
|
t&.join
|
||||||
t.join
|
rp&.close
|
||||||
end
|
|
||||||
wp.close if wp
|
|
||||||
rp.close if rp
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_init_options!(isolate:, snapshot:, max_memory:, marshal_stack_depth:, ensure_gc_after_idle:, timeout:)
|
def check_init_options!(isolate:, snapshot:, max_memory:, marshal_stack_depth:, ensure_gc_after_idle:, timeout:)
|
||||||
|
|
Loading…
Add table
Reference in a new issue