Skip to content

Commit 910e1fa

Browse files
committed
Merging with develop
1 parent cf8c19d commit 910e1fa

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Diff for: kotlinx-coroutines-core/common/src/Builders.common.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ private class LazyStandaloneCoroutine(
207207
}
208208

209209
// Used by withContext when context changes, but dispatcher stays the same
210-
internal actual class UndispatchedCoroutine<in T>actual constructor (
210+
internal class UndispatchedCoroutine<in T>(
211211
context: CoroutineContext,
212212
uCont: Continuation<T>
213213
) : ScopeCoroutine<T>(if (context[UndispatchedMarker] == null) context + UndispatchedMarker else context, uCont) {
@@ -244,7 +244,7 @@ internal actual class UndispatchedCoroutine<in T>actual constructor (
244244
* - It's never accessed when we are sure there are no thread context elements
245245
* - It's cleaned up via [ThreadLocal.remove] as soon as the coroutine is suspended or finished.
246246
*/
247-
private val threadStateToRecover = ThreadLocal<Pair<CoroutineContext, Any?>>()
247+
private val threadStateToRecover = commonThreadLocal<Pair<CoroutineContext, Any?>?>(Symbol("UndispatchedCoroutine"))
248248

249249
/*
250250
* Indicates that a coroutine has at least one thread context element associated with it

Diff for: kotlinx-coroutines-core/common/src/CoroutineContext.common.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal expect fun wrapContextWithDebug(context: CoroutineContext): CoroutineCo
1414
/**
1515
* Executes a block using a given coroutine context.
1616
*/
17-
internal actual inline fun <T> withCoroutineContext(context: CoroutineContext, countOrElement: Any?, block: () -> T): T {
17+
internal inline fun <T> withCoroutineContext(context: CoroutineContext, countOrElement: Any?, block: () -> T): T {
1818
val oldValue = updateThreadContext(context, countOrElement)
1919
try {
2020
return block()
@@ -26,7 +26,7 @@ internal actual inline fun <T> withCoroutineContext(context: CoroutineContext, c
2626
/**
2727
* Executes a block using a context of a given continuation.
2828
*/
29-
internal actual inline fun <T> withContinuationContext(continuation: Continuation<*>, countOrElement: Any?, block: () -> T): T {
29+
internal inline fun <T> withContinuationContext(continuation: Continuation<*>, countOrElement: Any?, block: () -> T): T {
3030
val context = continuation.context
3131
val oldValue = updateThreadContext(context, countOrElement)
3232
val undispatchedCompletion = if (oldValue !== NO_THREAD_ELEMENTS) {
@@ -44,7 +44,7 @@ internal actual inline fun <T> withContinuationContext(continuation: Continuatio
4444
}
4545
}
4646

47-
internal fun Continuation<*>.updateUndispatchedCompletion(context: CoroutineContext, oldValue: Any?): UndispatchedCoroutine<*>? {
47+
private fun Continuation<*>.updateUndispatchedCompletion(context: CoroutineContext, oldValue: Any?): UndispatchedCoroutine<*>? {
4848
if (this !is CoroutineStackFrame) return null
4949
/*
5050
* Fast-path to detect whether we have undispatched coroutine at all in our stack.
@@ -65,7 +65,7 @@ internal fun Continuation<*>.updateUndispatchedCompletion(context: CoroutineCont
6565
return completion
6666
}
6767

68-
internal tailrec fun CoroutineStackFrame.undispatchedCompletion(): UndispatchedCoroutine<*>? {
68+
private tailrec fun CoroutineStackFrame.undispatchedCompletion(): UndispatchedCoroutine<*>? {
6969
// Find direct completion of this continuation
7070
val completion: CoroutineStackFrame = when (this) {
7171
is DispatchedCoroutine<*> -> return null
@@ -79,7 +79,7 @@ internal tailrec fun CoroutineStackFrame.undispatchedCompletion(): UndispatchedC
7979
* Marker indicating that [UndispatchedCoroutine] exists somewhere up in the stack.
8080
* Used as a performance optimization to avoid stack walking where it is not necessary.
8181
*/
82-
private object UndispatchedMarker: CoroutineContext.Element, CoroutineContext.Key<UndispatchedMarker> {
82+
internal object UndispatchedMarker: CoroutineContext.Element, CoroutineContext.Key<UndispatchedMarker> {
8383
override val key: CoroutineContext.Key<*>
8484
get() = this
8585
}

0 commit comments

Comments
 (0)