|
1 | 1 | --- |
2 | 2 | title: "task Class (Concurrency Runtime)" |
3 | | -ms.date: "11/04/2016" |
| 3 | +ms.date: "07/30/2019" |
4 | 4 | f1_keywords: ["task", "PPLTASKS/concurrency::task", "PPLTASKS/concurrency::task::task", "PPLTASKS/concurrency::task::get", "PPLTASKS/concurrency::task::is_apartment_aware", "PPLTASKS/concurrency::task::is_done", "PPLTASKS/concurrency::task::scheduler", "PPLTASKS/concurrency::task::then", "PPLTASKS/concurrency::task::wait"] |
5 | 5 | helpviewer_keywords: ["task class"] |
6 | 6 | ms.assetid: cdc3a8c0-5cbe-45a0-b5d5-e9f81d94df1a |
7 | 7 | --- |
8 | 8 | # task Class (Concurrency Runtime) |
9 | 9 |
|
10 | | -The Parallel Patterns Library (PPL) `task` class. A `task` object represents work that can be executed asynchronously, and concurrently with other tasks and parallel work produced by parallel algorithms in the Concurrency Runtime. It produces a result of type `_ResultType` on successful completion. Tasks of type `task<void>` produce no result. A task can be waited upon and canceled independently of other tasks. It can also be composed with other tasks using continuations( `then`), and join( `when_all`) and choice( `when_any`) patterns. |
| 10 | +The Parallel Patterns Library (PPL) `task` class. A `task` object represents work that can be executed asynchronously and concurrently with other tasks and parallel work produced by parallel algorithms in the Concurrency Runtime. It produces a result of type `_ResultType` on successful completion. Tasks of type `task<void>` produce no result. A task can be waited upon and canceled independently of other tasks. It can also be composed with other tasks using continuations( `then`), and join( `when_all`) and choice( `when_any`) patterns. When a task object is assigned to a new variable, the behavior is that of `std::shared_ptr`; in other words, both objects represent the same underlying task. |
11 | 11 |
|
12 | 12 | ## Syntax |
13 | 13 |
|
14 | 14 | ``` |
15 | | -template <typename T> |
16 | | -class task; |
17 | | -
|
18 | 15 | template <> |
19 | 16 | class task<void>; |
20 | 17 |
|
21 | | -template<typename _ReturnType> |
| 18 | +template<typename _ResultType> |
22 | 19 | class task; |
23 | 20 | ``` |
24 | 21 |
|
25 | 22 | #### Parameters |
26 | 23 |
|
27 | | -*T*<br/> |
28 | | -The task object type. |
29 | | - |
30 | | -*_ReturnType*<br/> |
31 | | -The result type of this task. |
| 24 | +*_ResultType*<br/> |
| 25 | +The type of the result that the task produces. |
32 | 26 |
|
33 | 27 | ## Members |
34 | 28 |
|
@@ -82,7 +76,7 @@ For more information, see [Task Parallelism](../../../parallel/concrt/task-paral |
82 | 76 | Returns the result this task produced. If the task is not in a terminal state, a call to `get` will wait for the task to finish. This method does not return a value when called on a task with a `result_type` of `void`. |
83 | 77 |
|
84 | 78 | ``` |
85 | | -_ReturnType get() const; |
| 79 | +_ResultType get() const; |
86 | 80 |
|
87 | 81 | void get() const; |
88 | 82 | ``` |
@@ -131,7 +125,7 @@ The function returns true if the task is completed or canceled (with or without |
131 | 125 | Determines whether two `task` objects represent different internal tasks. |
132 | 126 |
|
133 | 127 | ``` |
134 | | -bool operator!= (const task<_ReturnType>& _Rhs) const; |
| 128 | +bool operator!= (const task<_ResultType>& _Rhs) const; |
135 | 129 |
|
136 | 130 | bool operator!= (const task<void>& _Rhs) const; |
137 | 131 | ``` |
@@ -171,7 +165,7 @@ As `task` behaves like a smart pointer, after a copy assignment, this `task` obj |
171 | 165 | Determines whether two `task` objects represent the same internal task. |
172 | 166 |
|
173 | 167 | ``` |
174 | | -bool operator== (const task<_ReturnType>& _Rhs) const; |
| 168 | +bool operator== (const task<_ResultType>& _Rhs) const; |
175 | 169 |
|
176 | 170 | bool operator== (const task<void>& _Rhs) const; |
177 | 171 | ``` |
@@ -257,20 +251,20 @@ Adds a continuation task to this task. |
257 | 251 | template<typename _Function> |
258 | 252 | __declspec( |
259 | 253 | noinline) auto then(const _Function& _Func) const -> typename details::_ContinuationTypeTraits<_Function, |
260 | | - _ReturnType>::_TaskOfType; |
| 254 | + _ResultType>::_TaskOfType; |
261 | 255 |
|
262 | 256 | template<typename _Function> |
263 | 257 | __declspec( |
264 | 258 | noinline) auto then(const _Function& _Func, |
265 | 259 | const task_options& _TaskOptions) const -> typename details::_ContinuationTypeTraits<_Function, |
266 | | - _ReturnType>::_TaskOfType; |
| 260 | + _ResultType>::_TaskOfType; |
267 | 261 |
|
268 | 262 | template<typename _Function> |
269 | 263 | __declspec( |
270 | 264 | noinline) auto then(const _Function& _Func, |
271 | 265 | cancellation_token _CancellationToken, |
272 | 266 | task_continuation_context _ContinuationContext) const -> typename details::_ContinuationTypeTraits<_Function, |
273 | | - _ReturnType>::_TaskOfType; |
| 267 | + _ResultType>::_TaskOfType; |
274 | 268 |
|
275 | 269 | template<typename _Function> |
276 | 270 | __declspec( |
|
0 commit comments