All Synchronization Objects

All Synchronization Objects

A compact scan page for mutexes, condition variables, semaphores, latches, barriers, and async coordination objects 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 Synchronization Objects

Mutex and lock types

Condition-based waiting

Semaphores and phase coordination

Futures and promise-based synchronization

Practical rules

Example in practice

#include <mutex>
#include <condition_variable>
#include <thread>

int main() {
    std::mutex guard;
    std::condition_variable cv;
    bool ready = false;

    std::jthread worker([&] {
        std::scoped_lock lock(guard);
        ready = true;
        cv.notify_one();
    });

    std::unique_lock lock(guard);
    cv.wait(lock, [&] { return ready; });
    return 0;
}