elizarov
08/08/2017, 2:52 PMkotlinx.atomicfu
version 0.1 was released. This is an utility library that enables writing efficient and idiomatic Kotlin code with atomic variables, CAS, etc, without having to write companion objects with j.u.c.a.AtomicXXXFieldUpdater
instances. It is limited for now (only Maven projects are supported), but that is sufficient to use it in implementation of kotlinx.coroutines
(next version will use it). It is currently published to a separate Bintray repository and will soon be synced to JCenter. More details here: https://github.com/Kotlin/kotlinx.atomicfu/blob/master/README.mdvoddan
08/08/2017, 8:00 PMelizarov
08/08/2017, 8:02 PM::foo.delegate.compareAndSet
on a delegated property.groostav
08/08/2017, 9:06 PMval alpha by atomic(0.0)
val alphaCAS: AtomicUpdater<Double> = getUpdater(this::alpha)
val x = alpha //atomic read
alpha = x //atomic write
alphaCAS.loop { cur -> //while(true) volatile read
}
?elizarov
08/09/2017, 12:03 AMval fooAtomic = atomic(0)
val foo by fooAtomic
I'll think if I can implement this cleanly, so that only one volatile field is left is the bytecode after transfromation....mikehearn
08/10/2017, 2:34 PM