Dico
06/06/2019, 4:24 PMAtomicInt from kotlinx:atomicfu doesn't declare these:
operator fun plusAssign (+=)
operator fun minusAssign (-=)
operator fun inc (++)
operator fun dec (--)
In Java, these couldn't be atomic, but since you can implement them yourself, they would be.
For inc and dec I guess it might be because they would have to return AtomicInt, instead of Int.
Asking here because I didn't see an atomicfu channel.Ruckus
06/06/2019, 4:29 PMinc and dec, it would violate:
The(Emphasis added) https://kotlinlang.org/docs/reference/operator-overloading.htmlandinc()functions must return a value, which will be assigned to the variable on which thedec()or++operation was used. They shouldn't mutate the object on which the--orincwas invoked.dec
Dico
06/06/2019, 4:29 PMDico
06/06/2019, 4:30 PMRuckus
06/06/2019, 4:30 PMRuckus
06/06/2019, 4:31 PMDico
06/06/2019, 4:31 PMRuckus
06/06/2019, 4:33 PM