Compartilhar via


task Class

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.

Warning

This topic contains information for the C++ REST SDK 1.0 (codename "Casablanca"). If you are using a later version from the Codeplex Casablanca web page, then use the local documentation at http://casablanca.codeplex.com/documentation.

template <
   typename _Type
>
class task;

template <>
class task<void>;

template<
   typename _ReturnType
>
class task;

Parameters

  • _Type

  • T

  • _ReturnType
    The result type of this task.

Members

Public Typedefs

Name

Description

result_type

The type of the result an object of this class produces.

Public Constructors

Name

Description

task::task Constructor (C++ REST SDK)

Overloaded. Constructs a task object.

Public Methods

Name

Description

task::get Method (C++ REST SDK)

Overloaded. 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.

task::is_apartment_aware Method (C++ REST SDK)

Determines whether the task unwraps a Windows Runtime IAsyncInfo interface or is descended from such a task.

task::is_done Method

Determines if the task is completed.

task::scheduler Method

Returns the scheduler for this task

task::then Method (C++ REST SDK)

Overloaded. Adds a continuation task to this task.

task::wait Method (C++ REST SDK)

Waits for this task to reach a terminal state. It is possible for wait to execute the task inline, if all of the tasks dependencies are satisfied, and it has not already been picked up for execution by a background worker.

Public Operators

Name

Description

task::operator!= Operator (C++ REST SDK)

Overloaded. Determines whether two task objects represent different internal tasks.

task::operator= Operator (C++ REST SDK)

Overloaded. Replaces the contents of one task object with another.

task::operator== Operator (C++ REST SDK)

Overloaded. Determines whether two task objects represent the same internal task.

Remarks

For more information, see Task Parallelism (Concurrency Runtime).

Requirements

Header: pplxtasks.h

Namespace: pplx

See Also

Reference

pplx Namespace