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.
All Synchronization Objects
A compact scan page for mutexes, condition variables, semaphores, latches, barriers, and async coordination objects in the C++ standard library.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
std::mutexstd::recursive_mutexstd::timed_mutexstd::recursive_timed_mutexstd::shared_mutexstd::shared_timed_mutexstd::lock_guardstd::unique_lockstd::scoped_lockstd::shared_lockstd::condition_variablestd::condition_variable_anystd::notify_all_at_thread_exitstd::counting_semaphorestd::binary_semaphorestd::latchstd::barrierstd::futurestd::shared_futurestd::promisestd::packaged_taskstd::async#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;
}