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

余生颓废 提交于 2021-02-08 13:39:08

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!