Skip to content

Commit 3d31944

Browse files
committed
1 parent 14ca7f6 commit 3d31944

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

ext/stringio/stringio.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,6 +1750,11 @@ void
17501750
Init_stringio(void)
17511751
{
17521752
#undef rb_intern
1753+
1754+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
1755+
rb_ext_ractor_safe(true);
1756+
#endif
1757+
17531758
VALUE StringIO = rb_define_class("StringIO", rb_cData);
17541759

17551760
rb_define_const(StringIO, "VERSION", rb_str_new_cstr(STRINGIO_VERSION));

test/stringio/test_ractor.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: true
2+
require 'test/unit'
3+
4+
class TestStringIOInRactor < Test::Unit::TestCase
5+
def setup
6+
omit unless defined? Ractor
7+
end
8+
9+
def test_ractor
10+
assert_in_out_err([], <<-"end;", ["true"], [])
11+
require "stringio"
12+
$VERBOSE = nil
13+
r = Ractor.new do
14+
io = StringIO.new("")
15+
io.puts "abc"
16+
io.truncate(0)
17+
io.puts "def"
18+
"\0\0\0\0def\n" == io.string
19+
end
20+
puts r.take
21+
end;
22+
end
23+
end

0 commit comments

Comments
 (0)