It returns main Ractor, like Thread.main.
[Feature #17418]
This commit is contained in:
Koichi Sasada 2020-12-22 02:22:51 +09:00
Родитель 35471a9487
Коммит d0e4ccbefc
2 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -396,6 +396,13 @@ assert_equal 'ok', %q{
end end
} }
# Ractor.main returns main ractor
assert_equal 'true', %q{
Ractor.new{
Ractor.main
}.take == Ractor.current
}
# a ractor with closed outgoing port should terminate # a ractor with closed outgoing port should terminate
assert_equal 'ok', %q{ assert_equal 'ok', %q{
Ractor.new do Ractor.new do

Просмотреть файл

@ -768,4 +768,11 @@ class Ractor
def []=(sym, val) def []=(sym, val)
Primitive.ractor_local_value_set(sym, val) Primitive.ractor_local_value_set(sym, val)
end end
# returns main ractor
def self.main
__builtin_cexpr! %q{
rb_ractor_self(GET_VM()->ractor.main_ractor);
}
end
end end