cancel

abstract fun cancel(cause: Throwable? = null): Boolean

Close channel with optional cause cancellation. Unlike ByteWriteChannel.close that could close channel normally, cancel does always close with error so any operations on this channel will always fail and all suspensions will be resumed with exception.

Please note that if the channel has been provided by reader or writer then the corresponding owning coroutine will be cancelled as well

See Also

ByteWriteChannel.close