my $c = Channel.new;
Promise.in(1).then({$c.send(100500)});
say await $c;
my $c2 = Channel.new;
await (^5).map: {
start {
my $r = rand;
sleep $r;
$c2.send($r);
}
}
$c2.close;
say $c2.list;
my $c3 = Channel.new;
await Promise.allof(
start { sleep 0.5; $c3.send('1'); },
start { sleep 0.1; $c3.send('2'); }
);
$c3.close;
say $c3.list.join: ', ';
my @promises;
for (3,1,5,2) -> $a {
@promises.push(start {
sleep $a;
say $a;
})
}
await(|@promises);
say "It took $(now - ENTER now) seconds to run";