Thread support library

From Cppreference

< cpp
Jump to: navigation, search

Contents

[edit] Threads

Threads enable the program to execute across several processor cores.

Defined in header <thread>
thread (C++11)
manages a separate thread
(class)
Functions managing the current thread
Defined in namespace this_thread
yield (C++11)
hints the implementation to reschedule execution of threads
(function)
get_id (C++11)
returns the thread id of the current thread
(function)
sleep_for (C++11)
stops the execution of the current thread for a specified time duration
(function)
sleep_until (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>
mutex (C++11)
provides basic mutual exclusion facility
(class)
recursive_mutex (C++11)
provides mutual exclusion facility which can be locked recursively by the same thread
(class)
timed_mutex (C++11)
provides mutual exclusion facility which implements locking with a timeout
(class)
recursive_timed_mutex (C++11)
provides mutual exclusion facility which can be locked recursively
by the same thread and implements locking with a timeout
(class)
Generic mutex management
lock_guard (C++11)
implements strictly scope-based mutex ownership wrapper
(class template)
unique_lock (C++11)
implements movable mutex ownership wrapper
(class template)
Generic locking algorithms
try_lock (C++11)
locks specified mutexes/locks, returns false if at least one is unavailable
(function template)
lock (C++11)
locks specified mutexes/locks, blocks if at least one is unavailable
(function template)
Call once
once_flag (C++11)
helper object to ensure that call_once invokes the function only once
(class)
call_once (C++11)
invokes a function only once even if called from multiple threads
(function template)

[edit] Condition variables

condition_variable (C++11)
manages threads that wait on a mutex
(class)
condition_variable_any (C++11)
manages threads that wait on some condition
(class)
notify_all_at_thread_exit (C++11)

(function)

[edit] Futures

Defined in header <future>
promise (C++11)
stores a value for asynchronous retrieval
(class template)
packaged_task (C++11)
packages a function to store its return value for asynchronous retrieval
(class template)
future (C++11)
waits for a value that is set asynchronously
(class template)
shared_future (C++11)
waits for a value that is set asynchronously. The internal state is shared among several objects
(class template)
async (C++11)
provides a facility to launch a function in a new thread and acquire its return value asynchronously
(function template)