liveBook · Manning

Std::memory_order_release

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

A C++ memory-order value that gives an atomic store release semantics, making preceding operations visible to a thread that performs a matching acquire operation.

std::memory_order_release gives an atomic store release semantics: preceding operations become visible to a thread that performs a matching acquire operation. section 5.2.1 section 5.2.2

Release ordering is permitted for these atomic operation categories:

Releasing a spinlock

A spinlock built with std::atomic_flag uses test_and_set(std::memory_order_acquire) to lock and clear(std::memory_order_release) to unlock. section 5.2.2

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

How deep it goes
Defines which operation categories permit release ordering and illustrates flag clearing, while deferring detailed ordering consequences.
Examples
Uses std::atomic_flag::clear(std::memory_order_release) and a spinlock mutex's release-based unlock operation.
What you can do after
Understand which atomic operations may use release ordering and how it appears in flag clearing and spinlock unlocking.
How it connects
Connects atomic stores and read-modify-write operations with acquire semantics and spinlock mutexes.

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.