All Concurrency Primitives

All Concurrency Primitives

A compact scan page for the main thread, lock, waiting, task, and atomic primitives in the C++ standard library.

How to use this reference page

Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.

  • Scan the top of the page first to identify the primary types, functions, or algorithm families involved.
  • Use the nearby-page links when your question is really about a companion header, related algorithm family, or broader subsystem.
  • Validate tricky behavior with a small compileable example before relying on memory for details like invalidation, ordering, allocation, or lifetime rules.

All Concurrency Primitives

Use this as a quick map. For grouped discussion, see C++ concurrency library.

Thread objects and cooperative stop

Mutexes and locks

Condition variables and waiting

Coordination primitives

Futures and asynchronous task state

Atomics and memory ordering

High-level guidance

Example in practice

#include <thread>
#include <mutex>

int main() {
    std::mutex guard;
    std::jthread worker([&] {
        std::scoped_lock lock(guard);
    });
}