Are the "modify" operators like +=
, |=
, &=
etc atomic?
I know ++
is atomic (if you perform x++;
in two different threads "simultaneously", you will always end up with x
increased by 2, as opposed to x=x+1
with optimization switched off.)
What I wonder is whether variable |= constant
, and the likes are thread-safe or do I have to protect them with a mutex?
(...or is it CPU-dependent? In this case, how is it on ARM?)