diff options
author | Koichi Sasada <ko1@atdot.net> | 2020-11-10 18:21:11 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2020-11-11 15:49:02 +0900 |
commit | db31ace934e8b900e90853bd875f23195837b398 (patch) | |
tree | f9e1e0999b574c0adf974e885420781b2dbd5a15 /bootstraptest | |
parent | 1e8abe5d03ae386af82e2c95ef05170cd9791889 (diff) | |
download | ruby-db31ace934e8b900e90853bd875f23195837b398.tar.gz |
Threads in a ractor will be killed with the ractor
If a terminating ractor has child threads, then kill all child
threads.
Diffstat (limited to 'bootstraptest')
-rw-r--r-- | bootstraptest/test_ractor.rb | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb index 527059d97b..86a033cba8 100644 --- a/bootstraptest/test_ractor.rb +++ b/bootstraptest/test_ractor.rb @@ -396,6 +396,39 @@ assert_equal '[RuntimeError, "ok", true]', %q{ end } +# threads in a ractor will killed +assert_equal '{:ok=>3}', %q{ + Ractor.new Ractor.current do |main| + q = Queue.new + Thread.new do + q << true + loop{} + ensure + main << :ok + end + + Thread.new do + q << true + while true + end + ensure + main << :ok + end + + Thread.new do + q << true + sleep 1 + ensure + main << :ok + end + + # wait for the start of all threads + 3.times{q.pop} + end + + 3.times.map{Ractor.receive}.tally +} + # unshareable object are copied assert_equal 'false', %q{ obj = 'str'.dup @@ -516,7 +549,6 @@ assert_equal [false, true, false].inspect, %q{ results << check(C.new(false).freeze) # false } - # move example2: String # touching moved object causes an error assert_equal 'hello world', %q{ |