C++ Logo


Advanced search

Re: atomic_swap()

From: Phil Bouchard <boost_at_[hidden]>
Date: Fri, 16 Jul 2021 16:37:13 -0400
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 <http://www.fornux.com>

Received on 2021-07-16 15:37:17