Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Elaborate on winner {} and multiple *channels* (only)
  • Loading branch information
lizmat committed Apr 7, 2014
1 parent f6d09ab commit 8b9265f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions S17-concurrency/winner.t
Expand Up @@ -37,6 +37,9 @@ plan 3;
loop {
winner * {
more @c { @a.push: $:v }
# When using multiple channels, and they don't close simultaneously, there is a chance
# that the "done" section of a closed channel is executed more than once. Hence the
# the use of a hash, rather than just a simple counter.
done @c { %done{$:k}++; last if +%done == 2 }
}
}
Expand Down

0 comments on commit 8b9265f

Please sign in to comment.