jsMain.com.arkivanov.mvikotlin.utils.internal.Atomic.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of utils-internal-js Show documentation
Show all versions of utils-internal-js Show documentation
Kotlin Multiplatform MVI framework
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