summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-08-20 13:49:09 +1200
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-09-14 16:44:09 +1200
commit905e9c8093b2bb06def609975929465be0f41a0c (patch)
tree753a2894322c827b22b976322906d79eef14da13
parent6747cb575414cf781c79c263f68d7b70778efa24 (diff)
Simplify bitmasks for IO events.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3434
-rw-r--r--include/ruby/io.h6
-rw-r--r--io.c6
-rw-r--r--test/fiber/scheduler.rb4
3 files changed, 11 insertions, 5 deletions
diff --git a/include/ruby/io.h b/include/ruby/io.h
index 359282a31e..5774a3fc10 100644
--- a/include/ruby/io.h
+++ b/include/ruby/io.h
@@ -41,6 +41,12 @@
# define RB_WAITFD_OUT 0x004
#endif
+typedef enum {
+ RUBY_IO_READABLE = RB_WAITFD_IN,
+ RUBY_IO_WRITABLE = RB_WAITFD_OUT,
+ RUBY_IO_PRIORITY = RB_WAITFD_PRI,
+} rb_io_event_t;
+
#include "ruby/internal/dllexport.h"
RBIMPL_SYMBOL_EXPORT_BEGIN()
diff --git a/io.c b/io.c
index 3cf0285717..08865931bf 100644
--- a/io.c
+++ b/io.c
@@ -13381,9 +13381,9 @@ Init_IO(void)
rb_cIO = rb_define_class("IO", rb_cObject);
rb_include_module(rb_cIO, rb_mEnumerable);
- rb_define_const(rb_cIO, "WAIT_READABLE", INT2NUM(RB_WAITFD_IN));
- rb_define_const(rb_cIO, "WAIT_PRIORITY", INT2NUM(RB_WAITFD_PRI));
- rb_define_const(rb_cIO, "WAIT_WRITABLE", INT2NUM(RB_WAITFD_OUT));
+ rb_define_const(rb_cIO, "READABLE", INT2NUM(RUBY_IO_READABLE));
+ rb_define_const(rb_cIO, "WRITABLE", INT2NUM(RUBY_IO_WRITABLE));
+ rb_define_const(rb_cIO, "PRIORITY", INT2NUM(RUBY_IO_PRIORITY));
/* exception to wait for reading. see IO.select. */
rb_mWaitReadable = rb_define_module_under(rb_cIO, "WaitReadable");
diff --git a/test/fiber/scheduler.rb b/test/fiber/scheduler.rb
index 740496674a..5508f21cf7 100644
--- a/test/fiber/scheduler.rb
+++ b/test/fiber/scheduler.rb
@@ -119,11 +119,11 @@ class Scheduler
end
def wait_any(io, events, duration)
- unless (events & IO::WAIT_READABLE).zero?
+ unless (events & IO::READABLE).zero?
@readable[io] = Fiber.current
end
- unless (events & IO::WAIT_WRITABLE).zero?
+ unless (events & IO::WRITABLE).zero?
@writable[io] = Fiber.current
end