mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[stringio] Make stringio Ractor safe
https://github.com/ruby/stringio/commit/ee3fec7512 https://github.com/ruby/stringio/commit/18dcd045ef https://github.com/ruby/stringio/commit/18dcd045ef
This commit is contained in:
parent
14ca7f633c
commit
3d31944129
2 changed files with 28 additions and 0 deletions
|
@ -1750,6 +1750,11 @@ void
|
|||
Init_stringio(void)
|
||||
{
|
||||
#undef rb_intern
|
||||
|
||||
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
||||
rb_ext_ractor_safe(true);
|
||||
#endif
|
||||
|
||||
VALUE StringIO = rb_define_class("StringIO", rb_cData);
|
||||
|
||||
rb_define_const(StringIO, "VERSION", rb_str_new_cstr(STRINGIO_VERSION));
|
||||
|
|
23
test/stringio/test_ractor.rb
Normal file
23
test/stringio/test_ractor.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
# frozen_string_literal: true
|
||||
require 'test/unit'
|
||||
|
||||
class TestStringIOInRactor < Test::Unit::TestCase
|
||||
def setup
|
||||
omit unless defined? Ractor
|
||||
end
|
||||
|
||||
def test_ractor
|
||||
assert_in_out_err([], <<-"end;", ["true"], [])
|
||||
require "stringio"
|
||||
$VERBOSE = nil
|
||||
r = Ractor.new do
|
||||
io = StringIO.new("")
|
||||
io.puts "abc"
|
||||
io.truncate(0)
|
||||
io.puts "def"
|
||||
"\0\0\0\0def\n" == io.string
|
||||
end
|
||||
puts r.take
|
||||
end;
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue