Roman Elizarov | 1f74a2d | 2018-06-29 19:19:45 +0300 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
| 3 | */ |
| 4 | |
Sergey Mashkov | 25b2bc5 | 2017-08-24 21:24:47 +0300 | [diff] [blame] | 5 | package kotlinx.coroutines.experimental.io |
| 6 | |
Roman Elizarov | f2239e1 | 2018-01-10 16:25:25 +0300 | [diff] [blame] | 7 | import kotlinx.coroutines.experimental.* |
Roman Elizarov | 96d7a88 | 2017-08-30 15:17:05 +0300 | [diff] [blame] | 8 | import kotlin.coroutines.experimental.CoroutineContext |
Sergey Mashkov | 25b2bc5 | 2017-08-24 21:24:47 +0300 | [diff] [blame] | 9 | |
| 10 | internal open class ByteChannelCoroutine( |
| 11 | parentContext: CoroutineContext, |
| 12 | open val channel: ByteChannel |
| 13 | ) : AbstractCoroutine<Unit>(parentContext, active = true) { |
Roman Elizarov | 6640b2b | 2018-01-17 19:08:55 +0300 | [diff] [blame] | 14 | override fun onCancellation(cause: Throwable?) { |
Sergey Mashkov | 25b2bc5 | 2017-08-24 21:24:47 +0300 | [diff] [blame] | 15 | if (!channel.close(cause) && cause != null) |
| 16 | handleCoroutineException(context, cause) |
Sergey Mashkov | 25b2bc5 | 2017-08-24 21:24:47 +0300 | [diff] [blame] | 17 | } |
| 18 | } |