Skip to content

Commit 8fbdff4

Browse files
author
Sergey Mashkov
committed
IO: add close cause property to byte channel
1 parent a0cc115 commit 8fbdff4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

core/kotlinx-coroutines-io/src/main/kotlin/kotlinx/coroutines/experimental/io/ByteBufferChannel.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ internal class ByteBufferChannel(
9393
override var totalBytesWritten: Long = 0L
9494
private set
9595

96+
override val closedCause: Throwable?
97+
get() = closed?.cause
98+
9699
override fun close(cause: Throwable?): Boolean {
97100
if (closed != null) return false
98101
val newClosed = if (cause == null) ClosedElement.EmptyCause else ClosedElement(cause)

core/kotlinx-coroutines-io/src/main/kotlin/kotlinx/coroutines/experimental/io/ByteWriteChannel.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public interface ByteWriteChannel {
4343
*/
4444
public val totalBytesWritten: Long
4545

46+
/**
47+
* An closure cause exception or `null` if closed successfully or not yet closed
48+
*/
49+
public val closedCause: Throwable?
50+
4651
/**
4752
* Writes as much as possible and only suspends if buffer is full
4853
*/

0 commit comments

Comments
 (0)