Skip to content

Commit ba338b4

Browse files
committed
1 parent 88db082 commit ba338b4

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

ext/io/wait/wait.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@ io_wait(int argc, VALUE *argv, VALUE io)
273273
void
274274
Init_wait(void)
275275
{
276+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
277+
RB_EXT_RACTOR_SAFE(true);
278+
#endif
279+
276280
rb_define_method(rb_cIO, "nread", io_nread, 0);
277281
rb_define_method(rb_cIO, "ready?", io_ready_p, 0);
278282

test/io/wait/test_ractor.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
require 'test/unit'
3+
require 'rbconfig'
4+
require 'io/wait'
5+
6+
class TestIOWaitInRactor < Test::Unit::TestCase
7+
def setup
8+
omit unless defined? Ractor
9+
end
10+
11+
def test_ractor
12+
ext = "/io/wait.#{RbConfig::CONFIG['DLEXT']}"
13+
path = $".find {|path| path.end_with?(ext)}
14+
assert_in_out_err(%W[-r#{path}], <<-"end;", ["true"], [])
15+
$VERBOSE = nil
16+
r = Ractor.new do
17+
$stdout.equal?($stdout.wait_writable)
18+
end
19+
puts r.take
20+
end;
21+
end
22+
end

0 commit comments

Comments
 (0)