Medium
Classifying a CAS retry loop
Given this Treiber-stack push implementation (a CAS retry loop), how should it be classified under the formal non-blocking progress-guarantee hierarchy, and why?
main.cpp
struct Node { int value; Node* next; };
std::atomic<Node*> head{nullptr};
void push(Node* n) {
n->next = head.load(std::memory_order_relaxed);
while (!head.compare_exchange_weak(
n->next, n,
std::memory_order_release,
std::memory_order_relaxed)) {
// retry
}
}21 of 51 in Concurrency