ruby-changes:64346
From: Kenta <ko1@a...>
Date: Sun, 20 Dec 2020 00:41:04 +0900 (JST)
Subject: [ruby-changes:64346] de80b92891 (master): [pathname] Make Pathname Ractor safe (#3940)
https://git.ruby-lang.org/ruby.git/commit/?id=de80b92891 From de80b928910b7ca785725382cec53cb27f1d65ed Mon Sep 17 00:00:00 2001 From: Kenta Murata <mrkn@u...> Date: Sun, 20 Dec 2020 00:40:47 +0900 Subject: [pathname] Make Pathname Ractor safe (#3940) diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index f71cec1..6f4c8d2 100644 --- a/ext/pathname/pathname.c +++ b/ext/pathname/pathname.c @@ -1512,6 +1512,10 @@ path_f_pathname(VALUE self, VALUE str) https://github.com/ruby/ruby/blob/trunk/ext/pathname/pathname.c#L1512 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); diff --git a/test/pathname/test_ractor.rb b/test/pathname/test_ractor.rb new file mode 100644 index 0000000..9ce43ef --- /dev/null +++ b/test/pathname/test_ractor.rb @@ -0,0 +1,22 @@ https://github.com/ruby/ruby/blob/trunk/test/pathname/test_ractor.rb#L1 +# 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 + -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/