jvmMain.org.brightify.hyperdrive.utils.AtomicReference.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-utils-jvm Show documentation
Show all versions of kotlin-utils-jvm Show documentation
Module containing various utils used throughout Hyperdrive.
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