Simplify bitmasks for IO events.
This commit is contained in:
parent
6747cb5754
commit
905e9c8093
Notes:
git
2020-09-14 13:44:39 +09:00
@ -41,6 +41,12 @@
|
|||||||
# define RB_WAITFD_OUT 0x004
|
# define RB_WAITFD_OUT 0x004
|
||||||
#endif
|
#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"
|
#include "ruby/internal/dllexport.h"
|
||||||
RBIMPL_SYMBOL_EXPORT_BEGIN()
|
RBIMPL_SYMBOL_EXPORT_BEGIN()
|
||||||
|
|
||||||
|
6
io.c
6
io.c
@ -13381,9 +13381,9 @@ Init_IO(void)
|
|||||||
rb_cIO = rb_define_class("IO", rb_cObject);
|
rb_cIO = rb_define_class("IO", rb_cObject);
|
||||||
rb_include_module(rb_cIO, rb_mEnumerable);
|
rb_include_module(rb_cIO, rb_mEnumerable);
|
||||||
|
|
||||||
rb_define_const(rb_cIO, "WAIT_READABLE", INT2NUM(RB_WAITFD_IN));
|
rb_define_const(rb_cIO, "READABLE", INT2NUM(RUBY_IO_READABLE));
|
||||||
rb_define_const(rb_cIO, "WAIT_PRIORITY", INT2NUM(RB_WAITFD_PRI));
|
rb_define_const(rb_cIO, "WRITABLE", INT2NUM(RUBY_IO_WRITABLE));
|
||||||
rb_define_const(rb_cIO, "WAIT_WRITABLE", INT2NUM(RB_WAITFD_OUT));
|
rb_define_const(rb_cIO, "PRIORITY", INT2NUM(RUBY_IO_PRIORITY));
|
||||||
|
|
||||||
/* exception to wait for reading. see IO.select. */
|
/* exception to wait for reading. see IO.select. */
|
||||||
rb_mWaitReadable = rb_define_module_under(rb_cIO, "WaitReadable");
|
rb_mWaitReadable = rb_define_module_under(rb_cIO, "WaitReadable");
|
||||||
|
@ -119,11 +119,11 @@ class Scheduler
|
|||||||
end
|
end
|
||||||
|
|
||||||
def wait_any(io, events, duration)
|
def wait_any(io, events, duration)
|
||||||
unless (events & IO::WAIT_READABLE).zero?
|
unless (events & IO::READABLE).zero?
|
||||||
@readable[io] = Fiber.current
|
@readable[io] = Fiber.current
|
||||||
end
|
end
|
||||||
|
|
||||||
unless (events & IO::WAIT_WRITABLE).zero?
|
unless (events & IO::WRITABLE).zero?
|
||||||
@writable[io] = Fiber.current
|
@writable[io] = Fiber.current
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user