poll
ErrorsCollection

poll

Synthesised documentation from type/Channel

From type/Channel

See Original text in context

method poll(Channel:D:)

Receives and removes an item from the channel. If no item is present, returns Nil instead of waiting.

my $c = Channel.new;
Promise.in(2).then: { $c.close}
^10 .map({ $c.send($_); });
loop {
    if $c.poll -> $item { $item.say };
    if $c.closed  { last };
    sleep 0.1;
}

See method receive for a blocking version that properly responds to channel closing and failure.