
jvmMain.org.brightify.hyperdrive.utils.AtomicReference.kt Maven / Gradle / Ivy
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