C++ includes built-in support for threads, atomic operations, mutual exclusion, condition variables, and futures.
[edit] ThreadsThreads enable programs to execute across several processor cores.
manages a separate threadThe components stop source, stop token, and stop callback can be used to asynchronously request that an operation stops execution in a timely manner, typically because the result is no longer required. Such a request is called a stop request.
These components specify the semantics of shared access to a stop state. Any object modeling any of these components that refer to the same stop state is an associated stop source, stop token, or stop callback, respectively.
They are designed:
In fact, they do not even need to be used to "stop" anything, but can instead be used for a thread-safe one-time function(s) invocation trigger, for example.
[edit] Cache size access (since C++17) [edit] Atomic operationsThese components are provided for fine-grained atomic operations allowing for lockless concurrent programming. Each atomic operation is indivisible with regards to any other atomic operation that involves the same object. Atomic objects are free of data races.
Neither the _Atomic
macro, nor any of the non-macro global namespace declarations are provided by any C++ standard library header other than <stdatomic.h>.
Mutual exclusion algorithms prevent multiple threads from simultaneously accessing shared resources. This prevents data races and provides support for synchronization between threads.
provides basic mutual exclusion facilitytry_lock
A condition variable is a synchronization primitive that allows multiple threads to communicate with each other. It allows some number of threads to wait (possibly with a timeout) for notification from another thread that they may proceed. A condition variable is always associated with a mutex.
[edit] Semaphores (since C++20)A semaphore is a lightweight synchronization primitive used to constrain concurrent access to a shared resource. When either would suffice, a semaphore can be more efficient than a condition variable.
[edit] Latches and Barriers (since C++20)Latches and barriers are thread coordination mechanisms that allow any number of threads to block until an expected number of threads arrive. A latch cannot be reused, while a barrier can be used repeatedly.
[edit] FuturesThe standard library provides facilities to obtain values that are returned and to catch exceptions that are thrown by asynchronous tasks (i.e. functions launched in separate threads). These values are communicated in a shared state, in which the asynchronous task may write its return value or store an exception, and which may be examined, waited for, and otherwise manipulated by other threads that hold instances of std::future or std::shared_future that reference that shared state.
[edit] Safe reclamation (since C++26)Safe-reclamation techniques are most frequently used to straightforwardly resolve access-deletion races.
Read-Copy-Update mechanism allows an object to be protected by RCUstd::rcu_domain
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4