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:
parent
d62414b48f
commit
de80b92891
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
|
@ -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);
|
||||
|
|
22
test/pathname/test_ractor.rb
Normal file
22
test/pathname/test_ractor.rb
Normal 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
|
||||
|
Loading…
Reference in a new issue