summaryrefslogtreecommitdiff
path: root/ractor.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-12-22 01:05:52 +0900
committerKoichi Sasada <ko1@atdot.net>2020-12-22 06:09:42 +0900
commitc34c6a89cb7524050dc6f174da53a8159a7bbd64 (patch)
treed70546a64f72395acf9c09f5a0239097ddab7858 /ractor.c
parent520dcbd6009b07458d67309ae33a602d77062975 (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.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/ractor.c b/ractor.c
index 5937ac65bb..35fbc89a29 100644
--- a/ractor.c
+++ b/ractor.c
@@ -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)
{