mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
add Ractor.main
It returns main Ractor, like Thread.main. [Feature #17418]
This commit is contained in:
parent
35471a9487
commit
d0e4ccbefc
Notes:
git
2020-12-22 05:54:38 +09:00
2 changed files with 14 additions and 0 deletions
|
@ -396,6 +396,13 @@ assert_equal 'ok', %q{
|
|||
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
|
||||
assert_equal 'ok', %q{
|
||||
Ractor.new do
|
||||
|
|
|
@ -768,4 +768,11 @@ class Ractor
|
|||
def []=(sym, val)
|
||||
Primitive.ractor_local_value_set(sym, val)
|
||||
end
|
||||
|
||||
# returns main ractor
|
||||
def self.main
|
||||
__builtin_cexpr! %q{
|
||||
rb_ractor_self(GET_VM()->ractor.main_ractor);
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue