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.
Public Member Functions | Friends | List of all members
pplx::task_completion_event< _ResultType > Class Template Reference

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

#include <pplxtasks.h>

Public Member Functions

 task_completion_event ()
 Constructs a task_completion_event object. More...
 
bool set (_ResultType _Result) const
 Sets the task completion event. More...
 
template<typename _E >
 __declspec (noinline) bool set_exception(_E _Except) const
 
 __declspec (noinline) bool set_exception(std
 Propagates an exception to all tasks associated with this event. More...
 
bool _Cancel () const
 Internal method to cancel the task_completion_event. Any task created using this event will be marked as canceled if it has not already been set. More...
 
template<typename _ExHolderType >
bool _Cancel (_ExHolderType _ExHolder, const details::_TaskCreationCallstack &_SetExceptionAddressHint=details::_TaskCreationCallstack()) const
 Internal method to cancel the task_completion_event with the exception provided. Any task created using this event will be canceled with the same exception. More...
 
template<typename _ExHolderType >
bool _StoreException (_ExHolderType _ExHolder, const details::_TaskCreationCallstack &_SetExceptionAddressHint=details::_TaskCreationCallstack()) const
 Internal method that stores an exception in the task completion event. This is used internally by when_any. Note, this does not cancel the task completion event. A task completion event with a stored exception can bet set() successfully. If it is canceled, it will cancel with the stored exception, if one is present. More...
 
bool _IsTriggered () const
 Tests whether current event has been either Set, or Canceled. More...
 

Friends

template<typename T >
class task
 
template<typename T >
class task_completion_event
 

Detailed Description

template<typename _ResultType>
class pplx::task_completion_event< _ResultType >

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.

Template Parameters
_ResultTypeThe result type of this task_completion_event class.

Use a task created from a task completion event when your scenario requires you to create a task that will complete, and thereby have its continuations scheduled for execution, at some point in the future. The task_completion_event must have the same type as the task you create, and calling the set method on the task completion event with a value of that type will cause the associated task to complete, and provide that value as a result to its continuations.

If the task completion event is never signaled, any tasks created from it will be canceled when it is destructed.

task_completion_event behaves like a smart pointer, and should be passed by value.

See also
task Class

Constructor & Destructor Documentation

template<typename _ResultType>
pplx::task_completion_event< _ResultType >::task_completion_event ( )
inline

Constructs a task_completion_event object.

Member Function Documentation

template<typename _ResultType>
pplx::task_completion_event< _ResultType >::__declspec ( noinline  )
inline

Propagates an exception to all tasks associated with this event.

The exception_ptr that indicates the exception to set this event with.

template<typename _ResultType>
bool pplx::task_completion_event< _ResultType >::_Cancel ( ) const
inline

Internal method to cancel the task_completion_event. Any task created using this event will be marked as canceled if it has not already been set.

template<typename _ResultType>
template<typename _ExHolderType >
bool pplx::task_completion_event< _ResultType >::_Cancel ( _ExHolderType  _ExHolder,
const details::_TaskCreationCallstack _SetExceptionAddressHint = details::_TaskCreationCallstack () 
) const
inline

Internal method to cancel the task_completion_event with the exception provided. Any task created using this event will be canceled with the same exception.

template<typename _ResultType>
bool pplx::task_completion_event< _ResultType >::_IsTriggered ( ) const
inline

Tests whether current event has been either Set, or Canceled.

template<typename _ResultType>
template<typename _ExHolderType >
bool pplx::task_completion_event< _ResultType >::_StoreException ( _ExHolderType  _ExHolder,
const details::_TaskCreationCallstack _SetExceptionAddressHint = details::_TaskCreationCallstack () 
) const
inline

Internal method that stores an exception in the task completion event. This is used internally by when_any. Note, this does not cancel the task completion event. A task completion event with a stored exception can bet set() successfully. If it is canceled, it will cancel with the stored exception, if one is present.

template<typename _ResultType>
bool pplx::task_completion_event< _ResultType >::set ( _ResultType  _Result) const
inline

Sets the task completion event.

Parameters
_ResultThe result to set this event with.
Returns
The method returns true if it was successful in setting the event. It returns false if the event is already set.

In the presence of multiple or concurrent calls to set, only the first call will succeed and its result (if any) will be stored in the task completion event. The remaining sets are ignored and the method will return false. When you set a task completion event, all the tasks created from that event will immediately complete, and its continuations, if any, will be scheduled. Task completion objects that have a _ResultType other than void will pass the value to their continuations.


The documentation for this class was generated from the following file: