jvmMain.internal.Sharing.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlinx-coroutines-core
Show all versions of kotlinx-coroutines-core
Coroutines support libraries for Kotlin
/*
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
package kotlinx.coroutines.internal
import kotlinx.coroutines.*
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
import kotlin.internal.*
@Suppress("ACTUAL_WITHOUT_EXPECT") // visibility different
internal actual typealias ShareableRefHolder = Any
@InlineOnly
@Suppress("NOTHING_TO_INLINE") // Should be NOP
internal actual fun ShareableRefHolder.disposeSharedRef() {}
@InlineOnly
@Suppress("NOTHING_TO_INLINE") // Should be NOP
internal actual fun T.asShareable(): DisposableHandle where T : DisposableHandle, T : ShareableRefHolder = this
@InlineOnly
@Suppress("NOTHING_TO_INLINE") // Should be NOP
internal actual inline fun CoroutineDispatcher.asShareable(): CoroutineDispatcher = this
@InlineOnly
@Suppress("NOTHING_TO_INLINE") // Should be NOP
internal actual inline fun Continuation.asShareable() : Continuation = this
@InlineOnly
@Suppress("NOTHING_TO_INLINE") // Should be NOP
internal actual inline fun Continuation.asLocal() : Continuation = this
@InlineOnly
@Suppress("NOTHING_TO_INLINE") // Should be NOP
internal actual inline fun Continuation.asLocalOrNull() : Continuation? = this
@InlineOnly
@Suppress("NOTHING_TO_INLINE") // Should be NOP
internal actual fun Continuation.asLocalOrNullIfNotUsed() : Continuation? = this
@InlineOnly
@Suppress("NOTHING_TO_INLINE") // Should be NOP
internal actual inline fun Continuation.useLocal() : Continuation = this
@InlineOnly
@Suppress("NOTHING_TO_INLINE") // Should be NOP
internal actual inline fun Continuation.shareableInterceptedResumeCancellableWith(result: Result) {
intercepted().resumeCancellableWith(result)
}
@InlineOnly
@Suppress("NOTHING_TO_INLINE") // Should be NOP
internal actual inline fun Continuation.shareableInterceptedResumeWith(result: Result) {
intercepted().resumeWith(result)
}
@InlineOnly
@Suppress("NOTHING_TO_INLINE") // Should be NOP
internal actual inline fun disposeContinuation(cont: () -> Continuation<*>) {}
@InlineOnly
@Suppress("NOTHING_TO_INLINE") // Save an entry on call stack
internal actual inline fun CancellableContinuationImpl.shareableResume(delegate: Continuation, undispatched: Boolean) =
resume(delegate, undispatched)
@InlineOnly
@Suppress("NOTHING_TO_INLINE") // Should be NOP
internal actual inline fun (suspend (T) -> R).asShareable(): suspend (T) -> R = this
@InlineOnly
@Suppress("NOTHING_TO_INLINE") // Save an entry on call stack
internal actual inline fun isReuseSupportedInPlatform() = true
@InlineOnly
internal actual inline fun ArrayList.addOrUpdate(element: T, update: (ArrayList) -> Unit) {
add(element)
}
@InlineOnly
internal actual inline fun ArrayList.addOrUpdate(index: Int, element: T, update: (ArrayList) -> Unit) {
add(index, element)
}
@InlineOnly
@Suppress("NOTHING_TO_INLINE") // Should be NOP
internal actual inline fun Any.weakRef(): Any = this
@InlineOnly
@Suppress("NOTHING_TO_INLINE") // Should be NOP
internal actual inline fun Any?.unweakRef(): Any? = this