STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Concurrency::task_completion_event< void > 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 <ppltasks.h>

Public Member Functions

bool set () 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...
 
void _Cancel () const
 Cancel the task_completion_event. Any task created using this event will be marked as canceled if it has not already been set. More...
 
void _Cancel (const std::shared_ptr< details::_ExceptionHolder > &_ExHolder) const
 Cancel the task_completion_event with the exception holder provided. Any task created using this event will be canceled with the same exception. More...
 
bool _StoreException (const std::shared_ptr< details::_ExceptionHolder > &_ExHolder) const
 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
 Test whether current event has been either Set, or Canceled. More...
 

Private Member Functions

void _RegisterTask (details::_Task_ptr< details::_Unit_type >::_Type _TaskParam)
 Register a task with this event. This function is called when a task is constructed using a task_completion_event. More...
 

Private Attributes

task_completion_event< details::_Unit_type_M_unitEvent
 

Friends

template<typename T >
class task
 

Detailed Description

template<>
class Concurrency::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.

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

Member Function Documentation

template<typename _E >
Concurrency::task_completion_event< void >::__declspec ( noinline  ) const
inline
2907  {
2909  }
task_completion_event< details::_Unit_type > _M_unitEvent
Definition: ppltasks.h:2974
#define _CAPTURE_CALLSTACK()
Helper macro to determine how many stack frames need to be saved. When any number less or equal to 1 ...
Definition: ppltasks.h:162
bool _Cancel() const
Internal method to cancel the task_completion_event. Any task created using this event will be marked...
Definition: ppltasks.h:2725
exception_ptr make_exception_ptr(_E _Except)
Definition: exception:539
Concurrency::task_completion_event< void >::__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.

2920  {
2921  // It is important that _CAPTURE_CALLSTACK() evaluate to the instruction after the call instruction for set_exception.
2922  return _M_unitEvent._Cancel(_ExceptionPtr, _CAPTURE_CALLSTACK());
2923  }
task_completion_event< details::_Unit_type > _M_unitEvent
Definition: ppltasks.h:2974
#define _CAPTURE_CALLSTACK()
Helper macro to determine how many stack frames need to be saved. When any number less or equal to 1 ...
Definition: ppltasks.h:162
bool _Cancel() const
Internal method to cancel the task_completion_event. Any task created using this event will be marked...
Definition: ppltasks.h:2725
void Concurrency::task_completion_event< void >::_Cancel ( ) const
inline

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

2930  {
2932  }
task_completion_event< details::_Unit_type > _M_unitEvent
Definition: ppltasks.h:2974
bool _Cancel() const
Internal method to cancel the task_completion_event. Any task created using this event will be marked...
Definition: ppltasks.h:2725
void Concurrency::task_completion_event< void >::_Cancel ( const std::shared_ptr< details::_ExceptionHolder > &  _ExHolder) const
inline

Cancel the task_completion_event with the exception holder provided. Any task created using this event will be canceled with the same exception.

2939  {
2940  _M_unitEvent._Cancel(_ExHolder);
2941  }
task_completion_event< details::_Unit_type > _M_unitEvent
Definition: ppltasks.h:2974
bool _Cancel() const
Internal method to cancel the task_completion_event. Any task created using this event will be marked...
Definition: ppltasks.h:2725
bool Concurrency::task_completion_event< void >::_IsTriggered ( ) const
inline

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

2957  {
2958  return _M_unitEvent._IsTriggered();
2959  }
task_completion_event< details::_Unit_type > _M_unitEvent
Definition: ppltasks.h:2974
bool _IsTriggered() const
Tests whether current event has been either Set, or Canceled.
Definition: ppltasks.h:2773
void Concurrency::task_completion_event< void >::_RegisterTask ( details::_Task_ptr< details::_Unit_type >::_Type  _TaskParam)
inlineprivate

Register a task with this event. This function is called when a task is constructed using a task_completion_event.

2969  {
2970  _M_unitEvent._RegisterTask(_TaskParam);
2971  }
task_completion_event< details::_Unit_type > _M_unitEvent
Definition: ppltasks.h:2974
void _RegisterTask(const typename details::_Task_ptr< _ResultType >::_Type &_TaskParam)
Register a task with this event. This function is called when a task is constructed using a task_comp...
Definition: ppltasks.h:2846
bool Concurrency::task_completion_event< void >::_StoreException ( const std::shared_ptr< details::_ExceptionHolder > &  _ExHolder) const
inline

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.

2949  {
2950  return _M_unitEvent._StoreException(_ExHolder);
2951  }
task_completion_event< details::_Unit_type > _M_unitEvent
Definition: ppltasks.h:2974
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 whe...
Definition: ppltasks.h:2757

Sets the task completion event.

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.

2900  {
2902  }
task_completion_event< details::_Unit_type > _M_unitEvent
Definition: ppltasks.h:2974
unsigned char _Unit_type
Definition: ppltasks.h:247
bool set(_ResultType _Result) const
Sets the task completion event.
Definition: ppltasks.h:2651

Friends And Related Function Documentation

template<typename T >
friend class task
friend

Member Data Documentation


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