https://kotlinlang.org logo
#coroutines
Title
# coroutines
v

v0ldem0rt

09/06/2018, 6:12 PM
atomicfu seems like good fit but what difference it has with Java's
Atmoic*
j

Jonathan Walsh

09/06/2018, 6:19 PM
I’m not sure, I opened https://github.com/Kotlin/kotlinx.atomicfu/issues/26 to get a README section added on it
I only just found the atomicfu stuff yesterday
e

elizarov

09/06/2018, 7:20 PM
The difference is already explained in the first paragraph of its readme: “Code it like AtomicReference/Int/Long, but run it in production efficiently as AtomicXxxFieldUpdater on Kotlin/JVM”
👍 1
If that does not ring a bell, then you don’t need
atmoicfu
and you should just use java.util.concurrent.AtomicInt and its friends.
j

Jonathan Walsh

09/06/2018, 8:30 PM
oh, interesting. I did not know about FieldUpdaters. I think the question is still somewhat valid. If you get to code just like java atomics, but it is more efficient, why would you ever use java atomics?
k

kevinherron

09/06/2018, 8:48 PM
because there’s a big huge asterisk after “just like java atomics” if you keep reading
(do’s and don’ts section)
e

elizarov

09/06/2018, 8:54 PM
Also, like 99% of apps should not care about performance. But we develop generally-applicable libraries, so we must care about performance for that 1% and that is why we’ve created
atomicfu
to make our life easier (so that we can have nice code and good performance at the same time).
j

Jonathan Walsh

09/06/2018, 9:24 PM
Yeah, makes sense. Thanks for the info. Hopefully @v0ldem0rt also got an answer from this
v

v0ldem0rt

09/07/2018, 3:59 PM
Awesome thread @elizarov thanks as usual for adding your knowledge.
12 Views