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

jsMain.org.brightify.hyperdrive.utils.AtomicReference.kt Maven / Gradle / Ivy

package org.brightify.hyperdrive.utils

public actual class AtomicReference actual constructor(
    public actual var value: T
) {

    public actual fun compareAndSet(expected: T, new: T): Boolean {
        return if (value == expected) {
            value = new
            true
        } else {
            false
        }
    }

    public actual fun compareAndSwap(expected: T, new: T): T {
        return if (value == expected) {
            val old = value
            value = new
            old
        } else {
            new
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy