Skip to content

Instantly share code, notes, and snippets.

@gmazzo
gmazzo / NativeCollections.kt
Last active November 26, 2022 18:41
A Kotlin/Native thread-safe `List`, `Set` and `Map` implementations
package kotlin.native.concurrent
fun <T> AtomicReference<T>.computeAndSet(transform: T.() -> T) = with(value) {
@Suppress("ControlFlowWithEmptyBody")
while (!compareAndSet(this, transform().freeze()));
this
}