how work atomicCmpExchange under the hood?


To compare a double value from a background thread we can do atomicCmpExchange(…). But as the implementation of this function is hidden from the delphi source code, how it’s done under the hood ? on windows, but also on other platform ios/android (so on Firemonkey)

I would like to know if it’s safe from the main thread to do

::main thread
MyDouble := xxx;

and from a background thread to do

::background thread
if AtomicCmpExchange(MyDouble , -1, -1) = xxx then …. ;

Comments are closed.