Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Raku .hyper() and .race() example not working

Tags:

raku

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?

like image 841
user2944647 Avatar asked May 25 '20 07:05

user2944647


1 Answers

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;
like image 105
wamba Avatar answered Feb 03 '23 15:02

wamba