summaryrefslogtreecommitdiff
path: root/ext/-test-
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-08-01 06:49:07 +0900
committerGitHub <noreply@github.com>2021-08-01 06:49:07 +0900
commit3b52230452980f3afc6a7380276ea62f7c65e517 (patch)
tree51b1529d7a8897be325545d532e2f317f1dc0241 /ext/-test-
parent242f024bcbff6c46edd84a03365fa99ebd8eb524 (diff)
Define functions using rb_wait_for_single_fd [Bug #18046]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4696 Merged-By: nobu <nobu@ruby-lang.org>
Diffstat (limited to 'ext/-test-')
-rw-r--r--ext/-test-/thread_fd/thread_fd.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/-test-/thread_fd/thread_fd.c b/ext/-test-/thread_fd/thread_fd.c
index 3d3ec8a2e0..042b799dc8 100644
--- a/ext/-test-/thread_fd/thread_fd.c
+++ b/ext/-test-/thread_fd/thread_fd.c
@@ -7,8 +7,24 @@ thread_fd_close(VALUE ign, VALUE fd)
return Qnil;
}
+static VALUE
+thread_fd_wait(VALUE ign, VALUE fd)
+{
+ int ret = rb_thread_wait_fd(NUM2INT(fd));
+ return INT2NUM(ret);
+}
+
+static VALUE
+thread_fd_writable(VALUE ign, VALUE fd)
+{
+ int ret = rb_thread_fd_writable(NUM2INT(fd));
+ return INT2NUM(ret);
+}
+
void
Init_thread_fd(void)
{
rb_define_singleton_method(rb_cIO, "thread_fd_close", thread_fd_close, 1);
+ rb_define_singleton_method(rb_cIO, "thread_fd_wait", thread_fd_wait, 1);
+ rb_define_singleton_method(rb_cIO, "thread_fd_writable", thread_fd_writable, 1);
}