1
0
Fork 0
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:
Sam Saffron 2022-02-22 15:41:23 +11:00
parent 5266fec597
commit bdb0977d81
No known key found for this signature in database
GPG key ID: B9606168D2FFD9F5

View file

@ -367,7 +367,7 @@ module MiniRacer
done = true
end
wp.write("done")
wp.close
# ensure we do not leak a thread in state
t.join
@ -376,12 +376,9 @@ module MiniRacer
rval
ensure
# exceptions need to be handled
if t && wp
wp.write("done")
t.join
end
wp.close if wp
rp.close if rp
wp&.close
t&.join
rp&.close
end
def check_init_options!(isolate:, snapshot:, max_memory:, marshal_stack_depth:, ensure_gc_after_idle:, timeout:)