Perl6多线程4: Promise allof / anyof

allof   : 所有代码块执行完成后才退出

anyof :只要有一个代码块执行完后就马上退出

要配合 await 一起用:

my $p = start {say 'a'};
my $p1 = start {sleep 4;say 'b';}
my $all = Promise.anyof($p,$p1);
await $all;

这个代码, 只会打印出: a

my $p = start {say 'a'};
my $p1 = start {sleep 4;say 'b';}
my $all = Promise.allof($p,$p1);
await $all;

这个代码会打印出: a, b

原文地址:https://www.cnblogs.com/perl6/p/7440508.html