diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2020-12-08 09:29:09 +1300 |
---|---|---|
committer | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2020-12-09 08:55:35 +1300 |
commit | 2553c5f94a5d51c2c5876b31e4c1521ad9be12f6 (patch) | |
tree | fc7b8fe6e578424b15dea0f8b94caa7a72b5c0a1 /test/fiber/scheduler.rb | |
parent | a4a92ae6d99a75e11165ca09c44ccf47cf342047 (diff) | |
download | ruby-2553c5f94a5d51c2c5876b31e4c1521ad9be12f6.tar.gz |
Add support for non-blocking `Process.wait`.
Diffstat (limited to 'test/fiber/scheduler.rb')
-rw-r--r-- | test/fiber/scheduler.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/fiber/scheduler.rb b/test/fiber/scheduler.rb index 7cf0c26459..b3c3eaff59 100644 --- a/test/fiber/scheduler.rb +++ b/test/fiber/scheduler.rb @@ -117,6 +117,13 @@ class Scheduler Process.clock_gettime(Process::CLOCK_MONOTONIC) end + def process_wait(pid, flags) + # This is a very simple way to implement a non-blocking wait: + Thread.new do + Process::Status.wait(pid, flags) + end.value + end + def io_wait(io, events, duration) unless (events & IO::READABLE).zero? @readable[io] = Fiber.current |