[ruby/io-wait] Declare as Ractor-safe

Fixes https://bugs.ruby-lang.org/issues/17659

https://github.com/ruby/io-wait/commit/ba338b4764
This commit is contained in:
Nobuyoshi Nakada 2021-03-05 17:40:39 +09:00
parent ea81fff564
commit f6d5de8f33
Notes: git 2021-03-07 09:54:58 +09:00
2 changed files with 26 additions and 0 deletions

View File

@ -273,6 +273,10 @@ io_wait(int argc, VALUE *argv, VALUE io)
void void
Init_wait(void) Init_wait(void)
{ {
#ifdef HAVE_RB_EXT_RACTOR_SAFE
RB_EXT_RACTOR_SAFE(true);
#endif
rb_define_method(rb_cIO, "nread", io_nread, 0); rb_define_method(rb_cIO, "nread", io_nread, 0);
rb_define_method(rb_cIO, "ready?", io_ready_p, 0); rb_define_method(rb_cIO, "ready?", io_ready_p, 0);

View File

@ -0,0 +1,22 @@
# frozen_string_literal: true
require 'test/unit'
require 'rbconfig'
require 'io/wait'
class TestIOWaitInRactor < Test::Unit::TestCase
def setup
omit unless defined? Ractor
end
def test_ractor
ext = "/io/wait.#{RbConfig::CONFIG['DLEXT']}"
path = $".find {|path| path.end_with?(ext)}
assert_in_out_err(%W[-r#{path}], <<-"end;", ["true"], [])
$VERBOSE = nil
r = Ractor.new do
$stdout.equal?($stdout.wait_writable)
end
puts r.take
end;
end
end