Skip to content

Commit

Permalink
Duct-tape fix for #2930
Browse files Browse the repository at this point in the history
  • Loading branch information
qwwdfsad committed Apr 13, 2022
1 parent 90fa892 commit bb22ae6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kotlinx-coroutines-core/jvm/src/CoroutineContext.kt
Expand Up @@ -181,6 +181,14 @@ internal actual class UndispatchedCoroutine<in T>actual constructor (
*/
private var threadStateToRecover = ThreadLocal<Pair<CoroutineContext, Any?>>()

init {
// TODO explain this
if (uCont.context[ContinuationInterceptor] !is CoroutineDispatcher) {
val values = updateThreadContext(context, null)
threadStateToRecover.set(context to values)
}
}

fun saveThreadContext(context: CoroutineContext, oldValue: Any?) {
threadStateToRecover.set(context to oldValue)
}
Expand Down

0 comments on commit bb22ae6

Please sign in to comment.