consume ordering
/ consume -> kuhn-SOOM /
Consume ordering was a clever idea that did not survive contact with real compilers. It is a weaker, cheaper cousin of acquire: instead of ordering EVERYTHING after the load, it promises to order only the operations that actually DEPEND on the value loaded — those reached by following the pointer you just read. On weakly-ordered hardware like ARM and POWER, the chip enforces such 'data dependency' ordering for free, so consume was meant to capture exactly that and avoid a costly barrier.
The idea: if you do p = atomic_load(&head, memory_order_consume) and then read p->next, the read of p->next is 'carries-a-dependency' from the load, so it is ordered after it — but an unrelated global read is NOT, which is what makes it cheaper than acquire. This builds a narrower happens-before edge that flows only along the chain of data dependencies, perfect for traversing a lock-free linked structure published by a release store.
Why discouraged? Tracking the dependency chain through arbitrary source code (across function calls, through the optimizer that loves to break dependencies via value speculation or by turning a dependency into a control branch) proved unworkable. Every major compiler simply implements memory_order_consume AS memory_order_acquire — silently strengthening it — so you pay acquire's price and gain nothing portable. The C++ committee has formally discouraged its use pending a redesign, and Rust never offered it at all. Practical advice: use acquire; do not write new code with consume.
Node *p = atomic_load_explicit(&head, memory_order_consume); int v = p->value; /* the read of p->value carries a dependency from p */ /* every real compiler today compiles this consume as an acquire */
Dependency-ordered traversal — elegant in theory, but in practice it is just an acquire wearing a different name.
Do not write new code with memory_order_consume: it is formally discouraged, universally implemented as acquire, and the dependency rules are subtle enough that even experts get them wrong — reach for acquire instead.