Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/thread"

From cppreference.com
< cpp
(Futures: +c++11)
(Futures: move to templates)
Line 59: Line 59:
 
{{dcl list begin}}
 
{{dcl list begin}}
 
{{dcl list header | future}}
 
{{dcl list header | future}}
{{dcl list tclass | cpp/thread/promise | stores a value for asynchronous retrieval | notes={{mark c++11}}}}
+
{{dcl list template | cpp/thread/dcl list promise}}
{{dcl list tclass | cpp/thread/packaged_task | packages a function to store its return value for asynchronous retrieval | notes={{mark c++11}}}}
+
{{dcl list template | cpp/thread/dcl list packaged_task}}
{{dcl list tclass | cpp/thread/future | waits for a value that is set asynchronously | notes={{mark c++11}}}}
+
{{dcl list template | cpp/thread/dcl list future}}
{{dcl list tclass | cpp/thread/shared_future | waits for a value that is set asynchronously. The internal state is shared among several objects | notes={{mark c++11}}}}
+
{{dcl list template | cpp/thread/dcl list shared_future}}
{{dcl list tfun | cpp/thread/async | provides a facility to launch a function in a new thread and acquire its return value asynchronously | notes={{mark c++11}}}}
+
{{dcl list template | cpp/thread/dcl list async}}
{{dcl list enum | cpp/thread/async/launch | specifies the launch policy for {{c|std::async}} | notes={{mark c++11}}}}
+
{{dcl list template | cpp/thread/dcl list launch}}
 
{{dcl list end}}
 
{{dcl list end}}

Revision as of 01:39, 23 April 2012

Template:cpp/thread/sidebar

Contents

Threads

Threads enable the program to execute across several processor cores.

Template:cpp/thread/dcl list threadTemplate:cpp/thread/dcl list yieldTemplate:cpp/thread/dcl list get idTemplate:cpp/thread/dcl list sleep forTemplate:cpp/thread/dcl list sleep until
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.

Template:cpp/thread/dcl list mutexTemplate:cpp/thread/dcl list timed mutexTemplate:cpp/thread/dcl list recursive mutexTemplate:cpp/thread/dcl list recursive timed mutexTemplate:cpp/thread/dcl list lock guardTemplate:cpp/thread/dcl list unique lockTemplate:cpp/thread/dcl list lock tag tTemplate:cpp/thread/dcl list lock tagTemplate:cpp/thread/dcl list try lockTemplate:cpp/thread/dcl list lockTemplate:cpp/thread/dcl list once flagTemplate:cpp/thread/dcl list call once
Defined in header <mutex>
Generic mutex management
Generic locking algorithms
Call once

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 varibale 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)

Futures

Template:cpp/thread/dcl list promiseTemplate:cpp/thread/dcl list packaged taskTemplate:cpp/thread/dcl list futureTemplate:cpp/thread/dcl list shared futureTemplate:cpp/thread/dcl list asyncTemplate:cpp/thread/dcl list launch
Defined in header <future>