C++ Concurrency Library
C++ Concurrency Library
Threads, jthread, stop tokens, mutexes, atomics, futures, semaphores, latches, barriers, and the main coordination tools in the standard library.
C++ Concurrency Library
Threads, jthread, stop tokens, mutexes, atomics, futures, semaphores, latches, barriers, and the main coordination tools in the standard library.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
std::thread: raw thread object that must be joined or detachedstd::jthread: joining thread with cooperative cancellation supportstd::stop_source, std::stop_token, std::stop_callbackstd::mutex, std::recursive_mutex, std::timed_mutexstd::shared_mutex, std::shared_timed_mutexstd::lock_guard, std::unique_lock, std::scoped_lock, std::shared_lockstd::condition_variable, std::condition_variable_anystd::latchstd::barrierstd::counting_semaphore, std::binary_semaphorestd::future, std::shared_futurestd::promisestd::packaged_taskstd::asyncstd::atomic<T>memory_order_relaxed, memory_order_acquire, memory_order_release, memory_order_seq_cststd::jthread when ownership and lifetime are local<future><atomic><mutex><shared_mutex><condition_variable><semaphore><barrier>#include <thread>
#include <mutex>
int main() {
std::mutex guard;
std::jthread worker([&] {
std::scoped_lock lock(guard);
});
}