diff options
| author | Jean Boussier <jean.boussier@gmail.com> | 2025-03-30 19:18:34 +0200 |
|---|---|---|
| committer | Jean Boussier <jean.boussier@gmail.com> | 2025-03-31 10:25:52 +0200 |
| commit | 5e421ce8d949a4f92568db359be0d188b66e58ca (patch) | |
| tree | 2a7453a38abeec76346a87490269bdcdfad80e43 /test/ruby | |
| parent | 2263e26f40cd99166824851f6ae2ae4c8aed5ccd (diff) | |
ractor: don't inherit the default thread group
[Bug #17506]
`Thread.current.group` isn't shareable so it shouldn't be inherited
by the main thread of a new Ractor.
This cause an extra allocation when spawning a ractor, which could
be elided with a bit of extra work, but not sure if it's worth
the effort.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13013
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_ractor.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_ractor.rb b/test/ruby/test_ractor.rb index 5275768113..ec94df361f 100644 --- a/test/ruby/test_ractor.rb +++ b/test/ruby/test_ractor.rb @@ -60,6 +60,17 @@ class TestRactor < Test::Unit::TestCase assert_unshareable(x, "can not make shareable object for #<Method: String(Kernel)#itself()>", exception: Ractor::Error) end + def test_default_thread_group + assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + Warning[:experimental] = false + + main_ractor_id = Thread.current.group.object_id + ractor_id = Ractor.new { Thread.current.group.object_id }.take + refute_equal main_ractor_id, ractor_id + end; + end + def assert_make_shareable(obj) refute Ractor.shareable?(obj), "object was already shareable" Ractor.make_shareable(obj) |
