All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jsAndWasmSharedMain.internal.Concurrent.kt Maven / Gradle / Ivy

There is a newer version: 1.10.1
Show newest version
package kotlinx.coroutines.internal

internal actual typealias ReentrantLock = NoOpLock

internal actual inline fun  ReentrantLock.withLock(action: () -> T) = action()

internal class NoOpLock {
    fun tryLock() = true
    fun unlock(): Unit {}
}

internal actual fun  identitySet(expectedSize: Int): MutableSet = HashSet(expectedSize)

internal actual class WorkaroundAtomicReference actual constructor(private var value: V) {

    public actual fun get(): V = value

    public actual fun set(value: V) {
        this.value = value
    }

    public actual fun getAndSet(value: V): V {
        val prev = this.value
        this.value = value
        return prev
    }

    public actual fun compareAndSet(expected: V, value: V): Boolean {
        if (this.value === expected) {
            this.value = value
            return true
        }
        return false
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy