зеркало из https://github.com/github/ruby.git
[pathname] Make Pathname Ractor safe (#3940)
This commit is contained in:
Родитель
d62414b48f
Коммит
de80b92891
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
Загрузка…
Ссылка в новой задаче