Fork me on GitHub
#beginners
<
2019-09-21
>
ho0man04:09:02

Hi, everyone Are an Atom's swaps in danger of starvation ? (since I looked at the code and didn't find a mechanism to prioritize older swaps or am I wrong?)

ho0man04:09:38

We wanted to use atom in a stream-processing (kind-of) application. But we need to make sure that swaps don't get delayed indefinitely.

ataggart05:09:22

Under the covers it's just invoking AtomicReference.compareAndSet in a loop, so there is the chance of livelocking a thread if the value of the atom keeps changing between reading the old value and calling CAS.