liveBook · Manning

Std::memory_order

As explained in C++ Concurrency in Action, Second Edition

`std::memory_order` is a C++ standard library enumeration whose values specify memory-ordering constraints for atomic operations.

`std::memory_order` provides values for specifying the memory-ordering semantics of atomic operations. If no value is supplied, the operation uses `std::memory_order_seq_cst`, the strongest ordering. The precise semantics of the values require further study. section 5.2.1

The operation category determines which values are permitted:

  • Stores: `relaxed`, `release`, or `seq_cst`. section 5.2.1
  • Loads: `relaxed`, `consume`, `acquire`, or `seq_cst`. section 5.2.1
  • Read-modify-write operations: `relaxed`, `consume`, `acquire`, `release`, `acq_rel`, or `seq_cst`. section 5.2.1

How C++ Concurrency in Action, Second Edition covers it

How deep it goes
Lists six values and their permitted operation categories, while deferring the values’ precise semantics.
What you can do after
Apply an ordering value by matching it to the atomic operation category; the precise semantics require further study.
How it connects
Connects atomic operations with stores, loads, and read-modify-write operations.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of C++ Concurrency in Action, Second Edition. The section links point to the parts of the book it draws on.