STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Public Attributes | Private Member Functions | List of all members
Concurrency::details::_PPLTaskHandle< _ReturnType, _DerivedTaskHandle, _BaseTaskHandle > Struct Template Reference

The _PPLTaskHandle is the strong-typed task handle base. All user task functions need to be wrapped in this task handler to be executable by PPL. By deriving from a different _BaseTaskHandle, it can be used for both initial tasks and continuation tasks. For initial tasks, _PPLTaskHandle will be derived from _UnrealizedChore_t, and for continuation tasks, it will be derived from _ContinuationTaskHandleBase. The life time of the _PPLTaskHandle object is be managed by runtime if task handle is scheduled. More...

#include <ppltasks.h>

Inheritance diagram for Concurrency::details::_PPLTaskHandle< _ReturnType, _DerivedTaskHandle, _BaseTaskHandle >:

Public Member Functions

 _PPLTaskHandle (const typename _Task_ptr< _ReturnType >::_Type &_PTask)
 
virtual ~_PPLTaskHandle ()
 
virtual void invoke () const
 
_Task_ptr_base _GetTaskImplBase () const
 

Public Attributes

_Task_ptr< _ReturnType >::_Type _M_pTask
 

Private Member Functions

_PPLTaskHandle const & operator= (_PPLTaskHandle const &)
 

Detailed Description

template<typename _ReturnType, typename _DerivedTaskHandle, typename _BaseTaskHandle>
struct Concurrency::details::_PPLTaskHandle< _ReturnType, _DerivedTaskHandle, _BaseTaskHandle >

The _PPLTaskHandle is the strong-typed task handle base. All user task functions need to be wrapped in this task handler to be executable by PPL. By deriving from a different _BaseTaskHandle, it can be used for both initial tasks and continuation tasks. For initial tasks, _PPLTaskHandle will be derived from _UnrealizedChore_t, and for continuation tasks, it will be derived from _ContinuationTaskHandleBase. The life time of the _PPLTaskHandle object is be managed by runtime if task handle is scheduled.

Template Parameters
_ReturnTypeThe result type of the _Task_impl.
_DerivedTaskHandleThe derived task handle class. The operator () needs to be implemented.
_BaseTaskHandleThe base class from which _PPLTaskHandle should be derived. This is either _UnrealizedChore_t or _ContinuationTaskHandleBase.

Constructor & Destructor Documentation

template<typename _ReturnType, typename _DerivedTaskHandle, typename _BaseTaskHandle>
Concurrency::details::_PPLTaskHandle< _ReturnType, _DerivedTaskHandle, _BaseTaskHandle >::_PPLTaskHandle ( const typename _Task_ptr< _ReturnType >::_Type _PTask)
inline
1580  : _M_pTask(_PTask)
1581  {
1582  }
_Task_ptr< _ReturnType >::_Type _M_pTask
Definition: ppltasks.h:1635
template<typename _ReturnType, typename _DerivedTaskHandle, typename _BaseTaskHandle>
virtual Concurrency::details::_PPLTaskHandle< _ReturnType, _DerivedTaskHandle, _BaseTaskHandle >::~_PPLTaskHandle ( )
inlinevirtual
1585  {
1586  // Here is the sink of all task completion code paths
1587  _M_pTask->_M_taskEventLogger._LogTaskCompleted();
1588  }
_Task_ptr< _ReturnType >::_Type _M_pTask
Definition: ppltasks.h:1635

Member Function Documentation

template<typename _ReturnType, typename _DerivedTaskHandle, typename _BaseTaskHandle>
_Task_ptr_base Concurrency::details::_PPLTaskHandle< _ReturnType, _DerivedTaskHandle, _BaseTaskHandle >::_GetTaskImplBase ( ) const
inline
1631  {
1632  return _M_pTask;
1633  }
_Task_ptr< _ReturnType >::_Type _M_pTask
Definition: ppltasks.h:1635
template<typename _ReturnType, typename _DerivedTaskHandle, typename _BaseTaskHandle>
virtual void Concurrency::details::_PPLTaskHandle< _ReturnType, _DerivedTaskHandle, _BaseTaskHandle >::invoke ( ) const
inlinevirtual
1591  {
1592  // All exceptions should be rethrown to finish cleanup of the task collection. They will be caught and handled
1593  // by the runtime.
1594  _ASSERTE((bool)_M_pTask);
1595  if (!_M_pTask->_TransitionedToStarted())
1596  {
1597  static_cast<const _DerivedTaskHandle *>(this)->_SyncCancelAndPropagateException();
1598  return;
1599  }
1600 
1601  _M_pTask->_M_taskEventLogger._LogTaskExecutionStarted();
1602  try
1603  {
1604  // All derived task handle must implement this contract function.
1605  static_cast<const _DerivedTaskHandle *>(this)->_Perform();
1606  }
1607  catch(const task_canceled &)
1608  {
1609  _M_pTask->_Cancel(true);
1610  }
1611  catch(const _Interruption_exception &)
1612  {
1613  _M_pTask->_Cancel(true);
1614  }
1615 #if defined (__cplusplus_winrt)
1616  catch(::Platform::Exception^ _E)
1617  {
1618  _M_pTask->_CancelWithException(_E);
1619  }
1620 #endif /* defined (__cplusplus_winrt) */
1621  catch(...)
1622  {
1623  _M_pTask->_CancelWithException(std::current_exception());
1624  }
1625  _M_pTask->_M_taskEventLogger._LogTaskExecutionCompleted();
1626  }
exception_ptr current_exception()
Definition: exception:527
_Task_ptr< _ReturnType >::_Type _M_pTask
Definition: ppltasks.h:1635
#define _ASSERTE(expr)
Definition: crtdbg.h:216
template<typename _ReturnType, typename _DerivedTaskHandle, typename _BaseTaskHandle>
_PPLTaskHandle const& Concurrency::details::_PPLTaskHandle< _ReturnType, _DerivedTaskHandle, _BaseTaskHandle >::operator= ( _PPLTaskHandle< _ReturnType, _DerivedTaskHandle, _BaseTaskHandle > const &  )
private

Member Data Documentation

template<typename _ReturnType, typename _DerivedTaskHandle, typename _BaseTaskHandle>
_Task_ptr<_ReturnType>::_Type Concurrency::details::_PPLTaskHandle< _ReturnType, _DerivedTaskHandle, _BaseTaskHandle >::_M_pTask

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