Sujet : Re: Atomic caching of smart pointers
De : Bonita.Montero (at) *nospam* gmail.com (Bonita Montero)
Groupes : comp.lang.c++Date : 16. Sep 2024, 18:06:51
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vc9oj8$2v5hb$1@raubtier-asyl.eternal-september.org>
References : 1 2 3
User-Agent : Mozilla Thunderbird
Am 16.09.2024 um 08:01 schrieb Paavo Helde:
Meanwhile I think I found a bug in my posted code, I should probably
use compare_exchange_strong() instead of compare_exchange_weak().
Usually you loop with compare_exchange_xxx() if the word in memory has
changed. Re-evaluating the changed data may take some time. Therefore
there's compare_exchange_weak() which loops itself when the word hasn't
changed. It's better to use it if your re-evaluation after a false
-result may take some time and you plan to compile your code on a
machine with load-linked / store-conditional. On x86-CPUs both
functions are the same.