diff options
author | Koichi Sasada <ko1@atdot.net> | 2020-12-22 01:05:52 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2020-12-22 06:09:42 +0900 |
commit | c34c6a89cb7524050dc6f174da53a8159a7bbd64 (patch) | |
tree | d70546a64f72395acf9c09f5a0239097ddab7858 /ractor.c | |
parent | 520dcbd6009b07458d67309ae33a602d77062975 (diff) |
fix ractor's doc. [ci skip]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3960
Diffstat (limited to 'ractor.c')
-rw-r--r-- | ractor.c | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -1935,16 +1935,25 @@ ractor_moved_missing(int argc, VALUE *argv, VALUE self) * ClosedError is a descendant of StopIteration, so the closing of the ractor will break * the loops without propagating the error: * - * r = Ractor.new { 3.times { puts "Received: " + receive } } + * r = Ractor.new do + * loop do + * msg = receive # raises ClosedError and loop traps it + * puts "Received: #{msg}" + * end + * puts "loop exited" + * end * - * loop { r.send "test" } + * 3.times{|i| r << i} + * r.close_incoming + * r.take * puts "Continue successfully" * * This will print: * - * Received: test - * Received: test - * Received: test + * Received: 0 + * Received: 1 + * Received: 2 + * loop exited * Continue successfully */ @@ -2004,7 +2013,6 @@ ractor_moved_missing(int argc, VALUE *argv, VALUE self) * */ - void Init_Ractor(void) { |