Vsevolod Tolstopyatov | 79414ec | 2018-08-30 16:50:56 +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 | |
| 5 | package kotlinx.coroutines.experimental.internal |
| 6 | |
| 7 | import kotlinx.coroutines.experimental.* |
| 8 | import kotlin.coroutines.experimental.* |
| 9 | |
| 10 | internal class ScopeOwnerCoroutine<R>( |
| 11 | parentContext: CoroutineContext |
| 12 | ) : AbstractCoroutine<R>(parentContext, true), CoroutineScope { |
| 13 | |
| 14 | override val coroutineContext: CoroutineContext = parentContext + this |
| 15 | |
| 16 | /* |
| 17 | * Always return true, so final exception is in the scope before its completion. |
| 18 | */ |
| 19 | override fun cancel(cause: Throwable?): Boolean { |
| 20 | super.cancel(cause) |
| 21 | return true |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | internal class ContextScope(context: CoroutineContext) : CoroutineScope { |
| 26 | override val coroutineContext: CoroutineContext = context |
| 27 | } |