method receive

Documentation for method receive assembled from the following types:

class Channel

From Channel

(Channel) method receive

Defined as:

method receive(Channel:D:)

Receives and removes an item from the channel. It blocks if no item is present, waiting for a send from another thread.

Throws an exception of type X::Channel::ReceiveOnClosed if the channel has been closed, and the last item has been removed already, or if close is called while receive is waiting for an item to arrive.

If the channel has been marked as erratic with method fail, and the last item has been removed, throws the argument that was given to fail as an exception.

See method poll for a non-blocking version that won't throw exceptions.

my $c = Channel.new;
$c.send(1);
say $c.receive# OUTPUT: «1␤»