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...
 
void _ClearStoredException () const
 Internal method that observe and clear the exception stored in the task completion event. This is used internally by when_any. 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 _Ty >
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
2650  {
2652  }
task_completion_event< details::_Unit_type > _M_unitEvent
Definition: ppltasks.h:2726
exception_ptr make_exception_ptr(_Ex _Except) _NOEXCEPT
Definition: exception:378
#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:118
bool _Cancel() const
Internal method to cancel the task_completion_event. Any task created using this event will be marked...
Definition: ppltasks.h:2439
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.

2663  {
2664  // It is important that _CAPTURE_CALLSTACK() evaluates to the instruction after the call instruction for set_exception.
2665  return _M_unitEvent._Cancel(_ExceptionPtr, _CAPTURE_CALLSTACK());
2666  }
task_completion_event< details::_Unit_type > _M_unitEvent
Definition: ppltasks.h:2726
#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:118
bool _Cancel() const
Internal method to cancel the task_completion_event. Any task created using this event will be marked...
Definition: ppltasks.h:2439
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.

2673  {
2675  }
task_completion_event< details::_Unit_type > _M_unitEvent
Definition: ppltasks.h:2726
bool _Cancel() const
Internal method to cancel the task_completion_event. Any task created using this event will be marked...
Definition: ppltasks.h:2439
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.

2682  {
2683  _M_unitEvent._Cancel(_ExHolder);
2684  }
task_completion_event< details::_Unit_type > _M_unitEvent
Definition: ppltasks.h:2726
bool _Cancel() const
Internal method to cancel the task_completion_event. Any task created using this event will be marked...
Definition: ppltasks.h:2439
void Concurrency::task_completion_event< void >::_ClearStoredException ( ) const
inline

Internal method that observe and clear the exception stored in the task completion event. This is used internally by when_any.

2701  {
2703  }
task_completion_event< details::_Unit_type > _M_unitEvent
Definition: ppltasks.h:2726
void _ClearStoredException() const
Internal method that observe and clear the exception stored in the task completion event...
Definition: ppltasks.h:2487
bool Concurrency::task_completion_event< void >::_IsTriggered ( ) const
inline

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

2709  {
2710  return _M_unitEvent._IsTriggered();
2711  }
task_completion_event< details::_Unit_type > _M_unitEvent
Definition: ppltasks.h:2726
bool _IsTriggered() const
Tests whether current event has been either Set, or Canceled.
Definition: ppltasks.h:2500
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.

2721  {
2722  _M_unitEvent._RegisterTask(_TaskParam);
2723  }
task_completion_event< details::_Unit_type > _M_unitEvent
Definition: ppltasks.h:2726
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:2573
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.

2692  {
2693  return _M_unitEvent._StoreException(_ExHolder);
2694  }
task_completion_event< details::_Unit_type > _M_unitEvent
Definition: ppltasks.h:2726
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:2471

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.

2643  {
2645  }
task_completion_event< details::_Unit_type > _M_unitEvent
Definition: ppltasks.h:2726
unsigned char _Unit_type
Definition: ppltasks.h:192
bool set(_ResultType _Result) const
Sets the task completion event.
Definition: ppltasks.h:2368

Friends And Related Function Documentation

template<typename _Ty >
friend class task
friend

Member Data Documentation


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