From c34c6a89cb7524050dc6f174da53a8159a7bbd64 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Tue, 22 Dec 2020 01:05:52 +0900 Subject: fix ractor's doc. [ci skip] --- ractor.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'ractor.c') 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) { -- cgit v1.2.3