X::Channel::ReceiveOnClosed
X::Channel::ReceiveOnClosed
Channel은 스레드나 스케줄러 사이에서 메시지를 주고받을 때 쓰는 통로예요. 그런데 이미 닫힌 채널에서 receive를 호출하면 메시지를 받을 수가 없죠. 그때 던져지는 예외가 X::Channel::ReceiveOnClosed예요.
본문
Channel이 닫힌 상태에서 receive를 호출하면 이 예외가 발생해요.
my $s = Channel.new;
$s.close;
$s.receive; # Cannot receive a message on a closed channel
CATCH { default { put .^name, ': ', .Str } };
# OUTPUT: «X::Channel::ReceiveOnClosed: Cannot receive a message on a closed channel»
메서드
method channel
method Channel(X::Channel::ReceiveOnClosed:D: --> Channel:D)
receive가 호출됐던 그 Channel 객체를 돌려줘요. 어느 채널 때문에 예외가 났는지 확인할 때 써요.