jvmMain.internal.Concurrent.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-jvm Show documentation
Show all versions of kotlinx-coroutines-core-jvm Show documentation
Coroutines support libraries for Kotlin
The newest version!
package kotlinx.coroutines.internal
import java.util.*
import kotlin.concurrent.withLock as withLockJvm
@Suppress("ACTUAL_WITHOUT_EXPECT")
internal actual typealias ReentrantLock = java.util.concurrent.locks.ReentrantLock
internal actual inline fun ReentrantLock.withLock(action: () -> T) = this.withLockJvm(action)
@Suppress("ACTUAL_WITHOUT_EXPECT") // Visibility
internal actual typealias WorkaroundAtomicReference = java.util.concurrent.atomic.AtomicReference
// BenignDataRace is OptionalExpectation and doesn't have to be here
// but then IC breaks. See KT-66317
@Retention(AnnotationRetention.SOURCE)
@Target(AnnotationTarget.FIELD)
internal actual annotation class BenignDataRace()
@Suppress("NOTHING_TO_INLINE") // So that R8 can completely remove ConcurrentKt class
internal actual inline fun identitySet(expectedSize: Int): MutableSet =
Collections.newSetFromMap(IdentityHashMap(expectedSize))