1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[pathname] Make Pathname Ractor safe (#3940)

This commit is contained in:
Kenta Murata 2020-12-20 00:40:47 +09:00 committed by GitHub
parent d62414b48f
commit de80b92891
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2020-12-20 00:41:19 +09:00
Merged-By: mrkn <mrkn@ruby-lang.org>
2 changed files with 26 additions and 0 deletions

View file

@ -1512,6 +1512,10 @@ path_f_pathname(VALUE self, VALUE str)
void
Init_pathname(void)
{
#ifdef HAVE_RB_EXT_RACTOR_SAFE
rb_ext_ractor_safe(true);
#endif
InitVM(pathname);
rb_cPathname = rb_define_class("Pathname", rb_cObject);

View file

@ -0,0 +1,22 @@
# frozen_string_literal: true
require "test/unit"
require "pathname"
class TestPathnameRactor < Test::Unit::TestCase
def setup
skip unless defined? Ractor
end
def test_ractor_shareable
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
$VERBOSE = nil
require "pathname"
r = Ractor.new Pathname("a") do |x|
x.join(Pathname("b"), Pathname("c"))
end
assert_equal(Pathname("a/b/c"), r.take)
end;
end
end