ruby-changes:62916
From: Samuel <ko1@a...>
Date: Mon, 14 Sep 2020 13:44:28 +0900 (JST)
Subject: [ruby-changes:62916] 905e9c8093 (master): Simplify bitmasks for IO events.
https://git.ruby-lang.org/ruby.git/commit/?id=905e9c8093 From 905e9c8093b2bb06def609975929465be0f41a0c Mon Sep 17 00:00:00 2001 From: Samuel Williams <samuel.williams@o...> Date: Thu, 20 Aug 2020 13:49:09 +1200 Subject: Simplify bitmasks for IO events. diff --git a/include/ruby/io.h b/include/ruby/io.h index 359282a..5774a3f 100644 --- a/include/ruby/io.h +++ b/include/ruby/io.h @@ -41,6 +41,12 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/io.h#L41 # 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 3cf0285..0886593 100644 --- a/io.c +++ b/io.c @@ -13381,9 +13381,9 @@ Init_IO(void) https://github.com/ruby/ruby/blob/trunk/io.c#L13381 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 7404966..5508f21 100644 --- a/test/fiber/scheduler.rb +++ b/test/fiber/scheduler.rb @@ -119,11 +119,11 @@ class Scheduler https://github.com/ruby/ruby/blob/trunk/test/fiber/scheduler.rb#L119 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/