Skip to content

Commit 135ce6e

Browse files
committed
to iterate a channel, just use list context, duh
1 parent 2d03d45 commit 135ce6e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

S17-concurrency.pod

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RE-DRAFT: Synopsis 17: Concurrency
1414
Created: 3 Nov 2013
1515

1616
Last Modified: 13 Nov 2013
17-
Version: 4
17+
Version: 5
1818

1919
This synopsis is based around the concurrency primitives and tools currently
2020
being implemented in Rakudo on the JVM. It covers both things that are
@@ -437,15 +437,17 @@ The C<winner> construct also works on channels, and will try to receive a value
437437
from the first C<Channel> that has one available. It can also be used in order
438438
to write a loop to receive from a channel until it is closed:
439439

440-
loop {
440+
gather loop {
441441
winner {
442-
when $c { say "Received $_" }
442+
when $c { take $_ }
443443
when $c.closed { last }
444444
}
445445
}
446446

447-
[Conjectural: this is such a common pattern that we might want to provide a
448-
$channel.each(-> $val { ... }) to factor it out.]
447+
This is such a common pattern that we make a channel in list context behave that way:
448+
449+
for @$channel -> $val { ... }
450+
for $channel.list -> $val { ... }
449451

450452
=head2 Supplies
451453

0 commit comments

Comments
 (0)