问题
The following example code should accelerate the execution of a Raku program:
for (1..4).race() {
say "Doing $_";
sleep 1;
}
say now - INIT now;
I remember, that it worked some time ago, but now I always end up with 4 seconds runtime. Also using .race() or adding parameters doesn't change anything. What does I have to do, to run 2 processes at the same time?
回答1:
You should use race with the named argument batch
and the statement prefix race.
say race for (1..4).race(batch=>1) {
say "Doing $_";
sleep 1.rand;$_
}
say now - INIT now;
来源:https://stackoverflow.com/questions/61997743/raku-hyper-and-race-example-not-working