summaryrefslogtreecommitdiff
path: root/bootstraptest
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-12-07 16:01:35 +0900
committerKoichi Sasada <ko1@atdot.net>2020-12-07 16:01:35 +0900
commitc2fa024e0220aca6e2437e56df2abf1a2368cbdf (patch)
treebbe108853e83749d2ef4ff16e053c4b9f6bd8d7e /bootstraptest
parentcc36e499f9403c2e3dd0514fc8f13ff485c10b82 (diff)
fix Thread's interrupt and Ractor#take issue
Thread's interrupt set Ractor's wakeup_status as interrupted, but the status remains next Ractor communication API. This patch makes to ignore the previous interrupt state. [Bug #17366] Also this patch solves the Thread#kill and Ractor#take issues.
Diffstat (limited to 'bootstraptest')
-rw-r--r--bootstraptest/test_ractor.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb
index a960d9d00f..d3ff65ae21 100644
--- a/bootstraptest/test_ractor.rb
+++ b/bootstraptest/test_ractor.rb
@@ -229,6 +229,26 @@ assert_equal 'ok', %q{
end
}
+# Can mix with Thread#interrupt and Ractor#take [Bug #17366]
+assert_equal 'err', %q{
+ Ractor.new{
+ t = Thread.current
+ begin
+ Thread.new{ t.raise "err" }.join
+ rescue => e
+ e.message
+ end
+ }.take
+}
+
+# Killed Ractor's thread yields nil
+assert_equal 'nil', %q{
+ Ractor.new{
+ t = Thread.current
+ Thread.new{ t.kill }.join
+ }.take.inspect #=> nil
+}
+
# Ractor.yield raises Ractor::ClosedError when outgoing port is closed.
assert_equal 'ok', %q{
r = Ractor.new Ractor.current do |main|