From fb28c854b3b4bcffd4c9b6cc34fbf4d43b4ead4c Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 17 Apr 2020 18:31:22 +0300 Subject: [PATCH] Fix structured concurrency in Context --- .../commonMain/kotlin/hep/dataforge/context/Context.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dataforge-context/src/commonMain/kotlin/hep/dataforge/context/Context.kt b/dataforge-context/src/commonMain/kotlin/hep/dataforge/context/Context.kt index b3adcbfd..3db334c2 100644 --- a/dataforge-context/src/commonMain/kotlin/hep/dataforge/context/Context.kt +++ b/dataforge-context/src/commonMain/kotlin/hep/dataforge/context/Context.kt @@ -8,10 +8,11 @@ import hep.dataforge.provider.Provider import hep.dataforge.provider.top import hep.dataforge.values.Value import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Job +import kotlinx.coroutines.SupervisorJob import mu.KLogger import mu.KotlinLogging import kotlin.coroutines.CoroutineContext -import kotlin.coroutines.EmptyCoroutineContext import kotlin.jvm.JvmName /** @@ -91,8 +92,9 @@ open class Context( config.action() } - override val coroutineContext: CoroutineContext - get() = EmptyCoroutineContext + override val coroutineContext: CoroutineContext = (parent ?: Global).coroutineContext.let { parenContext -> + parenContext + SupervisorJob(parenContext[Job]) + } /** * Detach all plugins and terminate context