isClosedForReceive

Returns true if this channel was closed by invocation of close on the SendChannel side and all previously sent items were already received, or if the receiving side was cancelled.

This means that calling receive will result in a ClosedReceiveChannelException or a corresponding cancellation cause. If the channel was closed because of an exception, it is considered closed, too, but is called a failed channel. All suspending attempts to receive an element from a failed channel throw the original close cause exception.

Note that if this property returns false, it does not guarantee that consecutive call to receive will succeed, as the channel can be concurrently closed right after the check. For such scenarios, it is recommended to use receiveCatching instead.

See also