c_plus_plus_thread

C++ Thread support library

https://en.cppreference.com/w/cpp/thread

C++ includes built-in support for threads, mutual exclusion, condition variables, and futures.

Threads

Threads enable programs to execute across several processor cores.

types are designed to enable thread cancellation for

, although they can also be used independently of

- for example to interrupt

waiting functions, or for a custom thread management implementation. 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.

<!– include nostopstate_t inside as helper –>

}}

Cache size access

Mutual exclusion

Mutual exclusion algorithms prevent multiple threads from simultaneously accessing shared resources. This prevents data races and provides support for synchronization between threads.

Condition variables

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.

Latches and Barriers

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.

}}

Futures

The 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

or

that reference that shared state.

See also

c_plus_plus_thread.txt · Last modified: 2024/05/01 04:23 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki