dimanche 24 avril 2022

using acquire memory barrier for std::atomic::exchange

There are spinlock implementations that use memory_order_acquire for std::atomic<T>::exchange. A release barrier is used for the unlock while an acquire is used for locking. Given that exchange is a read + modify + write operation, I'm trying to understand why that is valid as opposed to using memory_order_acqrel?

Aucun commentaire:

Enregistrer un commentaire