diff options
author | Koichi Sasada <ko1@atdot.net> | 2020-09-25 11:39:15 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2020-09-25 12:53:58 +0900 |
commit | d247dedade684d8ba04da4af891791e5ab5878ef (patch) | |
tree | 710e24f7f84d91d58d014cbba809d8d06f65b6eb /bootstraptest | |
parent | 52865263467b48c0f5af6d9548972dd1f9e5bee1 (diff) |
Ractor.yield should raise if out-port is closed
Ractor.yield should raise Ractor::ClosedError if current Ractor's
outgoing-port is closed.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3578
Diffstat (limited to 'bootstraptest')
-rw-r--r-- | bootstraptest/test_ractor.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb index c693a9c496..025d886152 100644 --- a/bootstraptest/test_ractor.rb +++ b/bootstraptest/test_ractor.rb @@ -225,6 +225,27 @@ assert_equal 'ok', %q{ end } +# Ractor.yield raises Ractor::ClosedError when outgoing port is closed. +assert_equal 'ok', %q{ + r = Ractor.new Ractor.current do |main| + Ractor.recv + main << true + Ractor.yield 1 + end + + r.close_outgoing + r << true + Ractor.recv + + begin + r.take + rescue Ractor::ClosedError + 'ok' + else + 'ng' + end +} + # Raise Ractor::ClosedError when try to send into a ractor with closed incoming port assert_equal 'ok', %q{ r = Ractor.new { Ractor.recv } |