Thread support library

From cppreference.com
< cpp
 
 
Thread support library
Threads
thread (C++11)
this_thread namespace
get_id (C++11)
yield (C++11)
sleep_for (C++11)
sleep_until (C++11)
Mutual exclusion
mutex (C++11)
timed_mutex (C++11)
Generic lock management
lock_guard (C++11)
unique_lock (C++11)
defer_lock_t
try_to_lock_t
adopt_lock_t
(C++11)
(C++11)
(C++11)
lock (C++11)
try_lock (C++11)
defer_lock
try_to_lock
adopt_lock
(C++11)
(C++11)
(C++11)
Condition variables
condition_variable (C++11)
condition_variable_any (C++11)
notify_all_at_thread_exit (C++11)
cv_status (C++11)
Futures
promise (C++11)
future (C++11)
shared_future (C++11)
packaged_task (C++11)
async (C++11)
launch (C++11)
future_status (C++11)
future_error (C++11)
future_category (C++11)
future_errc (C++11)
 

Contents

[edit] Threads

Threads enable the program to execute across several processor cores.

Defined in header <thread>
(C++11)
manages a separate thread
(class)
Functions managing the current thread
Defined in namespace this_thread
(C++11)
hints the implementation to reschedule execution of threads
(function)
(C++11)
returns the thread id of the current thread
(function)
(C++11)
stops the execution of the current thread for a specified time duration
(function)
(C++11)
stops the execution of the current thread until a specified time point
(function)

[edit] Mutual exclusion

Mutual exclusion algorithms restrict access to a shared resource so that only one thread can access it at a time. This allows to avoid data races and to implement synchronization between threads.

Defined in header <mutex>
(C++11)
provides basic mutual exclusion facility
(class)
(C++11)
provides mutual exclusion facility which implements locking with a timeout
(class)
provides mutual exclusion facility which can be locked recursively by the same thread
(class)
provides mutual exclusion facility which can be locked recursively
by the same thread and implements locking with a timeout
(class)
Generic mutex management
(C++11)
implements strictly scope-based mutex ownership wrapper
(class template)
(C++11)
implements movable mutex ownership wrapper
(class template)
tag type used to specify locking strategy
(class)
tag constants used to specify locking strategy
(constant)
Generic locking algorithms
(C++11)
locks specified mutexes/locks, returns false if at least one is unavailable
(function template)
(C++11)
locks specified mutexes/locks, blocks if at least one is unavailable
(function template)
Call once
(C++11)
helper object to ensure that call_once invokes the function only once
(class)
(C++11)
invokes a function only once even if called from multiple threads
(function template)

[edit] Condition variables

A condition variable is a synchronization primitive which implements a list of threads that are waiting until another thread notifies one or all of the waiting threads that they may proceed, until a timeout expires, or until a spurious wakeup occurs. A condition variable is always associated with a mutex.

provides a condition variable assocaited with std::unique_lock
(class)
provides a condition variable associated with any lock type
(class)
schedules a call to notify_all to be invoked when this thread exits
(function)
(C++11)
lists the possible results of timed waits on condition variables
(enum)

[edit] Futures

The standard library provides facilities to obtain values that are returned and to catch exceptions that are thrown by asynchronous tasks, that is, by the functions launched on 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.

Defined in header <future>
(C++11)
stores a value for asynchronous retrieval
(class template)
packages a function to store its return value for asynchronous retrieval
(class template)
(C++11)
waits for a value that is set asynchronously
(class template)
waits for a value that is set asynchronously. The internal state is shared among several objects
(class template)
(C++11)
provides a facility to launch a function in a new thread and acquire its return value asynchronously
(function template)
(C++11)
specifies the launch policy for std::async
(enum)
specifies the results of timed waits performed on std::future and std::shared_future
(enum)
(C++11)
reports an error related to futures or promises
(class)
identifies the future error category
(function)
(C++11)
identifies the future error codes
(enum)