blob: e2e7475c782ff79f8483e566149811880c1ea4d5 [file] [log] [blame]
Vsevolod Tolstopyatov79414ec2018-08-30 16:50:56 +03001/*
2 * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3 */
4
5package kotlinx.coroutines.experimental.internal
6
7import kotlinx.coroutines.experimental.*
8import kotlin.coroutines.experimental.*
9
10internal 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
25internal class ContextScope(context: CoroutineContext) : CoroutineScope {
26 override val coroutineContext: CoroutineContext = context
27}