aboutsummaryrefslogtreecommitdiffstats
path: root/scheduler.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-12-08 09:29:09 +1300
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-12-09 08:55:35 +1300
commit2553c5f94a5d51c2c5876b31e4c1521ad9be12f6 (patch)
treefc7b8fe6e578424b15dea0f8b94caa7a72b5c0a1 /scheduler.c
parenta4a92ae6d99a75e11165ca09c44ccf47cf342047 (diff)
downloadruby-2553c5f94a5d51c2c5876b31e4c1521ad9be12f6.tar.gz
Add support for non-blocking `Process.wait`.
Diffstat (limited to 'scheduler.c')
-rw-r--r--scheduler.c14
1 files changed, 14 insertions, 0 deletions
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)
{