C++ Rest SDK
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Classes | Typedefs | Enumerations | Functions
pplx Namespace Reference

The pplx namespace provides classes and functions that give you access to the Concurrency Runtime, a concurrent programming framework for C++. For more information, see Concurrency Runtime. More...

Classes

class  _Continuation_func_transformer
 A helper class template that transforms a continuation lambda that either takes or returns void, or both, into a lambda that takes and returns a non-void type (details::_Unit_type is used to substitute for void). This is to minimize the special handling required for 'void'. More...
 
class  _Continuation_func_transformer< _InType, void >
 
class  _Continuation_func_transformer< void, _OutType >
 
class  _Continuation_func_transformer< void, void >
 
class  _Init_func_transformer
 
class  _Init_func_transformer< void >
 
class  cancellation_token
 The cancellation_token class represents the ability to determine whether some operation has been requested to cancel. A given token can be associated with a task_group, structured_task_group, or task to provide implicit cancellation. It can also be polled for cancellation or have a callback registered for if and when the associated cancellation_token_source is canceled. More...
 
class  cancellation_token_registration
 The cancellation_token_registration class represents a callback notification from a cancellation_token. When the register method on a cancellation_token is used to receive notification of when cancellation occurs, a cancellation_token_registration object is returned as a handle to the callback so that the caller can request a specific callback no longer be made through use of the deregister method. More...
 
class  cancellation_token_source
 The cancellation_token_source class represents the ability to cancel some cancelable operation. More...
 
class  invalid_operation
 This class describes an exception thrown when an invalid operation is performed that is not more accurately described by another exception type thrown by the Concurrency Runtime. More...
 
struct  scheduler_ptr
 Represents a pointer to a scheduler. This class exists to allow the the specification of a shared lifetime by using shared_ptr or just a plain reference by using raw pointer. More...
 
class  scoped_lock
 A generic RAII wrapper for locks that implements the critical_section interface cpprest_synchronization::lock_guard More...
 
class  task
 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. More...
 
class  task< void >
 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. More...
 
class  task_canceled
 This class describes an exception thrown by the PPL tasks layer in order to force the current task to cancel. It is also thrown by the get() method on task, for a canceled task. More...
 
class  task_completion_event
 The task_completion_event class allows you to delay the execution of a task until a condition is satisfied, or start a task in response to an external event. More...
 
class  task_completion_event< void >
 The task_completion_event class allows you to delay the execution of a task until a condition is satisfied, or start a task in response to an external event. More...
 
class  task_continuation_context
 The task_continuation_context class allows you to specify where you would like a continuation to be executed. It is only useful to use this class from a Windows Store app. For non-Windows Store apps, the task continuation's execution context is determined by the runtime, and not configurable. More...
 
class  task_options
 Represents the allowed options for creating a task More...
 

Typedefs

typedef void(_pplx_cdecl * TaskProc_t) (void *)
 An elementary abstraction for a task, defined as void (__cdecl * TaskProc_t)(void *). A TaskProc is called to invoke the body of a task. More...
 
typedef details::linux_scheduler default_scheduler_t
 Default scheduler type More...
 
typedef task_group_status task_status
 A type that represents the terminal state of a task. Valid values are completed and canceled. More...
 

Enumerations

enum  task_group_status { not_complete, completed, canceled }
 Describes the execution status of a task_group or structured_task_group object. A value of this type is returned by numerous methods that wait on tasks scheduled to a task group to complete. More...
 

Functions

_PPLXIMP void _pplx_cdecl set_ambient_scheduler (std::shared_ptr< pplx::scheduler_interface > _Scheduler)
 Sets the ambient scheduler to be used by the PPL constructs. More...
 
_PPLXIMP std::shared_ptr< pplx::scheduler_interface > _pplx_cdecl get_ambient_scheduler ()
 Gets the ambient scheduler to be used by the PPL constructs More...
 
struct __declspec (novtable) scheduler_interface
 Scheduler Interface More...
 
 __attribute__ ((always_inline)) inline void *_ReturnAddress()
 
bool _pplx_cdecl is_task_cancellation_requested ()
 Returns an indication of whether the task that is currently executing has received a request to cancel its execution. Cancellation is requested on a task if the task was created with a cancellation token, and the token source associated with that token is canceled. More...
 
 __declspec (noreturn) void _pplx_cdecl cancel_current_task()
 Cancels the currently executing task. This function can be called from within the body of a task to abort the task's execution and cause it to enter the canceled state. While it may be used in response to the is_task_cancellation_requested function, you may also use it by itself, to initiate cancellation of the task that is currently executing. More...
 
template<typename _Ty >
 __declspec (noinline) auto create_task(_Ty _Param
 Creates a PPL task object. create_task can be used anywhere you would have used a task constructor. It is provided mainly for convenience, because it allows use of the auto keyword while creating tasks. More...
 

Detailed Description

The pplx namespace provides classes and functions that give you access to the Concurrency Runtime, a concurrent programming framework for C++. For more information, see Concurrency Runtime.

Typedef Documentation

Default scheduler type

A type that represents the terminal state of a task. Valid values are completed and canceled.

See also
task Class
typedef void(_pplx_cdecl * pplx::TaskProc_t) (void *)

An elementary abstraction for a task, defined as void (__cdecl * TaskProc_t)(void *). A TaskProc is called to invoke the body of a task.

Enumeration Type Documentation

Describes the execution status of a task_group or structured_task_group object. A value of this type is returned by numerous methods that wait on tasks scheduled to a task group to complete.

See also
task_group Class, task_group::wait Method, task_group::run_and_wait Method, structured_task_group Class, structured_task_group::wait Method, structured_task_group::run_and_wait Method
Enumerator
not_complete 

The tasks queued to the task_group object have not completed. Note that this value is not presently returned by the Concurrency Runtime.

completed 

The tasks queued to the task_group or structured_task_group object completed successfully.

canceled 

The task_group or structured_task_group object was canceled. One or more tasks may not have executed.

Function Documentation

struct pplx::__declspec ( novtable  )

Scheduler Interface

pplx::__declspec ( noreturn  )
inline

Cancels the currently executing task. This function can be called from within the body of a task to abort the task's execution and cause it to enter the canceled state. While it may be used in response to the is_task_cancellation_requested function, you may also use it by itself, to initiate cancellation of the task that is currently executing.

It is not a supported scenario to call this function if you are not within the body of a task. Doing so will result in undefined behavior such as a crash or a hang in your application.

See also
task Class
template<typename _Ty >
pplx::__declspec ( noinline  )

Creates a PPL task object. create_task can be used anywhere you would have used a task constructor. It is provided mainly for convenience, because it allows use of the auto keyword while creating tasks.

Template Parameters
_TyThe type of the parameter from which the task is to be constructed.
Parameters
_ParamThe parameter from which the task is to be constructed. This could be a lambda or function object, a task_completion_event object, a different task object, or a Windows::Foundation::IAsyncInfo interface if you are using tasks in your Windows Store app.
Returns
A new task of type T, that is inferred from _Param .

The first overload behaves like a task constructor that takes a single parameter.

The second overload associates the cancellation token provided with the newly created task. If you use this overload you are not allowed to pass in a different task object as the first parameter.

The type of the returned task is inferred from the first parameter to the function. If _Param is a task_completion_event<T>, a task<T>, or a functor that returns either type T or task<T>, the type of the created task is task<T>.

In a Windows Store app, if _Param is of type Windows::Foundation::IAsyncOperation<T>^ or Windows::Foundation::IAsyncOperationWithProgress<T,P>^, or a functor that returns either of those types, the created task will be of type task<T>. If _Param is of type Windows::Foundation::IAsyncAction^ or Windows::Foundation::IAsyncActionWithProgress<P>^, or a functor that returns either of those types, the created task will have type task<void>.

See also
task Class, Task Parallelism (Concurrency Runtime)
_PPLXIMP std::shared_ptr<pplx::scheduler_interface> _pplx_cdecl pplx::get_ambient_scheduler ( )

Gets the ambient scheduler to be used by the PPL constructs

bool _pplx_cdecl pplx::is_task_cancellation_requested ( )
inline

Returns an indication of whether the task that is currently executing has received a request to cancel its execution. Cancellation is requested on a task if the task was created with a cancellation token, and the token source associated with that token is canceled.

Returns
true if the currently executing task has received a request for cancellation, false otherwise.

If you call this method in the body of a task and it returns true, you must respond with a call to cancel_current_task to acknowledge the cancellation request, after performing any cleanup you need. This will abort the execution of the task and cause it to enter into the canceled state. If you do not respond and continue execution, or return instead of calling cancel_current_task, the task will enter the completed state when it is done. state.

A task is not cancellable if it was created without a cancellation token.

See also
task Class, cancellation_token_source Class, cancellation_token Class, cancel_current_task Function
_PPLXIMP void _pplx_cdecl pplx::set_ambient_scheduler ( std::shared_ptr< pplx::scheduler_interface >  _Scheduler)

Sets the ambient scheduler to be used by the PPL constructs.