In Channel§
See primary documentation in context for method receive.
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»