Ok thanks... and it is slow:


On 7/16/21 2:40 PM, Thiago Macieira via Std-Proposals wrote:
On Friday, 16 July 2021 11:28:46 PDT Phil Bouchard via Std-Proposals wrote:
I just realized that swap() is not using the XCHG assembly instruction
at all. Maybe adding an atomic_swap() could achieve this?
No, that won't work. You can't atomically swap two memory locations.

If only one of the two variables needs to be atomically swapped, we already 
have a function for that, atomic_exchange().


Phil Bouchard
Founder & CTO
C.: (819) 328-4743

Fornux Logo