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

jsMain.com.arkivanov.mvikotlin.utils.internal.Atomic.kt Maven / Gradle / Ivy

There is a newer version: 3.3.0
Show newest version
package com.arkivanov.mvikotlin.utils.internal

actual fun  atomic(value: T): AtomicRef = AtomicRefImpl(value)

private class AtomicRefImpl(
    override var value: T
) : AtomicRef {
    override fun compareAndSet(expected: T, new: T): Boolean =
        if (this.value === expected) {
            this.value = new
            true
        } else {
            false
        }
}

actual fun atomic(value: Boolean): AtomicBoolean = AtomicBooleanImpl(value)

private class AtomicBooleanImpl(
    override var value: Boolean
) : AtomicBoolean

actual fun atomic(value: Int): AtomicInt = AtomicIntImpl(value)

private class AtomicIntImpl(
    override var value: Int
) : AtomicInt




© 2015 - 2025 Weber Informatics LLC | Privacy Policy