Difference between revisions of "cpp/thread"
From cppreference.com
< cpp
(→Mutual exclusion: reorder) |
(incorrect descs for condvars) |
||
Line 44: | Line 44: | ||
===Condition variables=== | ===Condition variables=== | ||
− | + | A condition variable is a synchronization primitive which implements a queue 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. | |
{{dcl list begin}} | {{dcl list begin}} | ||
− | {{dcl list class | cpp/thread/condition_variable | | + | {{dcl list class | cpp/thread/condition_variable | provides a condition variable assocaited with std::unique_mutex | notes={{mark c++11}}}} |
− | {{dcl list class | cpp/thread/condition_variable_any | | + | {{dcl list class | cpp/thread/condition_variable_any | provides a condition varibale associated with any lock type | notes={{mark c++11}}}} |
− | {{dcl list fun | cpp/thread/notify_all_at_thread_exit | | notes={{mark c++11}}}} | + | {{dcl list fun | cpp/thread/notify_all_at_thread_exit | schedules a call to notify_all to be invoked when this thread exits | notes={{mark c++11}}}} |
+ | {{dcl list class | cpp/thread/cv_status | lists the possible results of timed waits on condition variables | notes={{mark c++11}}}} | ||
{{dcl list end}} | {{dcl list end}} | ||
Revision as of 12:09, 25 January 2012
Contents |
Threads
Threads enable the program to execute across several processor cores.
Defined in header
<thread> | |
Functions managing the current thread | |
Defined in namespace
this_thread |
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.
Condition variables
A condition variable is a synchronization primitive which implements a queue 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.
(C++11) |
provides a condition variable assocaited with std::unique_mutex (class) |
(C++11) |
provides a condition varibale associated with any lock type (class) |
(C++11) |
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 (class) |
Futures
This section is incomplete |
Defined in header
<future> | |
(C++11) |
stores a value for asynchronous retrieval (class template) |
(C++11) |
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) |
(C++11) |
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) |