File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
core/kotlinx-coroutines-io/src/main/kotlin/kotlinx/coroutines/experimental/io Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,16 @@ public interface ByteReadChannel {
145
145
*/
146
146
suspend fun read (min : Int = 1, block : (ByteBuffer ) -> Unit )
147
147
148
+ /* *
149
+ * Close channel with optional [cause] cancellation. Unlike [ByteWriteChannel.close] that could close channel
150
+ * normally, cancel does always close with error so any operations on this channel will always fail
151
+ * and all suspensions will be resumed with exception.
152
+ *
153
+ * Please note that if the channel has been provided by [reader] or [writer] then the corresponding owning
154
+ * coroutine will be cancelled as well
155
+ *
156
+ * @see ByteWriteChannel.close
157
+ */
148
158
fun cancel (cause : Throwable ? = null): Boolean
149
159
}
150
160
Original file line number Diff line number Diff line change @@ -129,6 +129,10 @@ public interface ByteWriteChannel {
129
129
* all subsequent write operations throw [ClosedWriteChannelException] or the specified [cause].
130
130
* However, [isClosedForRead][ByteReadChannel.isClosedForRead] on the side of [ByteReadChannel]
131
131
* starts returning `true` only after all written bytes have been read.
132
+ *
133
+ * Please note that if the channel has been closed with cause and it has been provided by [reader] or [writer]
134
+ * coroutine then the corresponding coroutine will be cancelled with [cause]. If no [cause] provided then no
135
+ * cancellation will be propagated.
132
136
*/
133
137
public fun close (cause : Throwable ? = null): Boolean
134
138
You can’t perform that action at this time.
0 commit comments