From 2553c5f94a5d51c2c5876b31e4c1521ad9be12f6 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Tue, 8 Dec 2020 09:29:09 +1300 Subject: Add support for non-blocking `Process.wait`. --- scheduler.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'scheduler.c') diff --git a/scheduler.c b/scheduler.c index 9ecb25f188..88db433f1e 100644 --- a/scheduler.c +++ b/scheduler.c @@ -18,6 +18,7 @@ static ID id_block; static ID id_unblock; static ID id_kernel_sleep; +static ID id_process_wait; static ID id_io_read; static ID id_io_write; @@ -32,6 +33,7 @@ Init_Scheduler(void) id_unblock = rb_intern_const("unblock"); id_kernel_sleep = rb_intern_const("kernel_sleep"); + id_process_wait = rb_intern_const("process_wait"); id_io_read = rb_intern_const("io_read"); id_io_write = rb_intern_const("io_write"); @@ -118,6 +120,18 @@ rb_scheduler_kernel_sleepv(VALUE scheduler, int argc, VALUE * argv) return rb_funcallv(scheduler, id_kernel_sleep, argc, argv); } +int +rb_scheduler_supports_process_wait(VALUE scheduler) +{ + return rb_respond_to(scheduler, id_process_wait); +} + +VALUE +rb_scheduler_process_wait(VALUE scheduler, rb_pid_t pid, int flags) +{ + return rb_funcall(scheduler, id_process_wait, 2, PIDT2NUM(pid), RB_INT2NUM(flags)); +} + VALUE rb_scheduler_block(VALUE scheduler, VALUE blocker, VALUE timeout) { -- cgit v1.2.1