I am implementing a lock-free queue based on this algorithm, which uses a counter to solve the ABA problem. But I don't know how to implement this counter with c++11 CAS. For example, from the algorithm:
E9: if CAS(&tail.ptr->next, next, <node, next.count+1>)
It is an atomic operation, meaning if tail.ptr-next is equal to next, let tail.ptr-next point to node and simultaneously(atomically) make next.count+1. However, using c++11 CAS, I can only implement:
std::atomic_compare_exchange_weak(&tail.ptr->next, next, node);
which cannot make next.count+1 simultaneously happen.
Aucun commentaire:
Enregistrer un commentaire