Ordering::Relaxed

This ordering didn't show up in the definition of happens-before/synchronizes-with. There's a very good reason for that. Relaxed ordering implies no guarantees. Loads and stores are free to be re-ordered around a load or store with relaxed ordering. That is, loads and stores can migrate up or down in program order from the point of view of a Relaxed operation.

The compiler and the hardware are free to do whatever they please in the presence of Relaxed ordering. There's quite a lot of utility in this, as we'll see in the upcoming detailed examples. For now, consider counters in a concurrent program used for self-telemetry, or data structures that have been designed to be eventually consistent. No need for strict ordering ...

Get Hands-On Concurrency with Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.