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

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

There is a newer version: 0.1.159
Show newest version
package org.brightify.hyperdrive.utils

import java.util.concurrent.atomic.AtomicReference as JAtomicReference

public actual class AtomicReference actual constructor(value: T) {
    private val storage = JAtomicReference(value)

    public actual var value: T
        get() = storage.get()
        set(newValue) {
            storage.set(newValue)
        }

    public actual fun compareAndSet(expected: T, new: T): Boolean {
        return storage.compareAndSet(expected, new)
    }

    public actual fun compareAndSwap(expected: T, new: T): T {
        return storage.compareAndExchange(expected, new)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy