Liste des Groupes | Revenir à cl c++ |
Am 16.09.24 um 08:01 schrieb Paavo Helde:The problem with weak is that it can spuriously fail. So, yup you need a loop. The strong one can be used for some older state machine algorithms I have seen. If a cas failed its simply because the comparands were different, not because of anything else...Meanwhile I think I found a bug in my posted code, I should probably use compare_exchange_strong() instead of compare_exchange_weak().Indeed. With ..._weak you most likely need a loop. But if you already have a loop for other purposes using the _weak function could avoid an additional loop in the implementation of the function.
I somehow thought the latter would err on the safe side, but it does not. In my test harness there seems to be no difference.On many platforms the underlying CAS primitives already are strong. In this cases both function are identical.
Marcel
Les messages affichés proviennent d'usenet.