STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Concurrency::details::_AsyncTaskCollection Class Reference

Async Task collections is a thin wrapper over task collection to cater to the execution of asynchronous chores (or tasks defined in ppltasks.h). Specifically, they manage their own lifetime by using reference counts. Scheduling a chore acquires a reference and on completion of its execution the reference is released. More...

#include <concrt.h>

Inheritance diagram for Concurrency::details::_AsyncTaskCollection:
Concurrency::details::_RefCounterBase

Public Member Functions

 _AsyncTaskCollection (const _AsyncTaskCollection &)=delete
 
_AsyncTaskCollectionoperator= (const _AsyncTaskCollection &)=delete
 
_TaskCollectionStatus _ScheduleWithAutoInline (_UnrealizedChore *_PChore, _TaskInliningMode _InliningMode)
 Schedule a chore with automatic inlining. The chore is pushed onto the associated workstealing queue, and will be executed in a LIFO order. The tasks scheduled into a _TaskCollection are scheduled into the current scheduler. Note that the specified chore can be scheduled only on a single task collection at a given time. Any attempt to schedule the same chore multiple times on one or more task collections will result in an invalid_multiple_scheduling exception. After the chore is guaranteed to have been executed (by calling the Wait method), it can be rescheduled to an arbitrary task collection. This schedule method will perform automatic inlining base on . More...
 
void _Cancel ()
 Cancels work on the task collection. More...
 
_TaskCollectionStatus _RunAndWait ()
 A cancellation friendly wrapper with which to execute _PChore and then waits for all chores running in the _TaskCollection to finish (normally or abnormally). This method encapsulates all the running tasks in an exception handling block, and will re-throw any exceptions that occur in any of it tasks (if those exceptions occur on another thread, they are marshaled from that thread to the thread where the _TaskCollection was created, and re-thrown). After this function returns, the _TaskCollection cannot be used for scheduling further work. More...
 
- Public Member Functions inherited from Concurrency::details::_RefCounterBase
virtual ~_RefCounterBase ()
 
long _Reference ()
 
long _Release ()
 

Static Public Member Functions

static _CONCRTIMP _AsyncTaskCollection *__cdecl _NewCollection (_CancellationTokenState *_PTokenState)
 Constructs a new task collection whose cancellation is governed by the specified cancellation token state. More...
 

Private Member Functions

void _NotificationHandler ()
 
virtual _CONCRTIMP void _Destroy ()
 
 _AsyncTaskCollection (_CancellationTokenState *_PTokenState)
 
 __declspec (noinline) static void __cdecl _CompletionHandler(void *_PCompletionContext)
 

Private Attributes

_TaskCollection _M_taskCollection
 

Additional Inherited Members

- Protected Member Functions inherited from Concurrency::details::_RefCounterBase
 _RefCounterBase (long _InitialCount=1)
 
- Protected Attributes inherited from Concurrency::details::_RefCounterBase
volatile long _M_refCount
 

Detailed Description

Async Task collections is a thin wrapper over task collection to cater to the execution of asynchronous chores (or tasks defined in ppltasks.h). Specifically, they manage their own lifetime by using reference counts. Scheduling a chore acquires a reference and on completion of its execution the reference is released.

Constructor & Destructor Documentation

Concurrency::details::_AsyncTaskCollection::_AsyncTaskCollection ( const _AsyncTaskCollection )
delete
Concurrency::details::_AsyncTaskCollection::_AsyncTaskCollection ( _CancellationTokenState _PTokenState)
private

Member Function Documentation

Concurrency::details::_AsyncTaskCollection::__declspec ( noinline  )
private
void Concurrency::details::_AsyncTaskCollection::_Cancel ( )
inline

Cancels work on the task collection.

5240  {
5242  }
_CONCRTIMP void _Cancel()
Cancels work on the task collection.
_TaskCollection _M_taskCollection
Definition: concrt.h:5279
virtual _CONCRTIMP void Concurrency::details::_AsyncTaskCollection::_Destroy ( )
privatevirtual
static _CONCRTIMP _AsyncTaskCollection* __cdecl Concurrency::details::_AsyncTaskCollection::_NewCollection ( _CancellationTokenState _PTokenState)
static

Constructs a new task collection whose cancellation is governed by the specified cancellation token state.

Parameters
_PTokenStateWhen this cancellation token is canceled, the task collection is canceled.
Returns
Pointer to a new instance of _AsyncTaskCollection.
void Concurrency::details::_AsyncTaskCollection::_NotificationHandler ( )
private
_TaskCollectionStatus Concurrency::details::_AsyncTaskCollection::_RunAndWait ( )
inline

A cancellation friendly wrapper with which to execute _PChore and then waits for all chores running in the _TaskCollection to finish (normally or abnormally). This method encapsulates all the running tasks in an exception handling block, and will re-throw any exceptions that occur in any of it tasks (if those exceptions occur on another thread, they are marshaled from that thread to the thread where the _TaskCollection was created, and re-thrown). After this function returns, the _TaskCollection cannot be used for scheduling further work.

Parameters
_PChoreAn _UnrealizedChore which when non-null will be called to invoke the chore in a cancellation friendly manner.
Returns
An indication of the status of the wait.
5258  {
5259  // Note that _Guard is NOT unused variable, the constructor and destructor will be called to maintain inline depth.
5260  _StackGuard _Guard;
5261  return _M_taskCollection._RunAndWait();
5262  }
_TaskCollection _M_taskCollection
Definition: concrt.h:5279
_CONCRTIMP _TaskCollectionStatus __stdcall _RunAndWait(_UnrealizedChore *_PChore=NULL)
A cancellation friendly wrapper with which to execute _PChore and then waits for all chores running i...
_TaskCollectionStatus Concurrency::details::_AsyncTaskCollection::_ScheduleWithAutoInline ( _UnrealizedChore _PChore,
_TaskInliningMode  _InliningMode 
)
inline

Schedule a chore with automatic inlining. The chore is pushed onto the associated workstealing queue, and will be executed in a LIFO order. The tasks scheduled into a _TaskCollection are scheduled into the current scheduler. Note that the specified chore can be scheduled only on a single task collection at a given time. Any attempt to schedule the same chore multiple times on one or more task collections will result in an invalid_multiple_scheduling exception. After the chore is guaranteed to have been executed (by calling the Wait method), it can be rescheduled to an arbitrary task collection. This schedule method will perform automatic inlining base on .

Parameters
_PChoreThe new unrealized chore need to be scheduled. The chore will be deleted after scheduling.
_InliningModeThe inlining scheduling policy for current chore.
Returns
An indication of current chore status after scheduling.
5212  {
5213  _CONCRT_ASSERT(_PChore != nullptr);
5214  _Reference();
5215 
5216  if (_InliningMode == _NoInline)
5217  {
5218  _M_taskCollection._Schedule(_PChore);
5219  return _NotComplete;
5220  }
5221  else
5222  {
5223  _StackGuard _Guard;
5224  if (_Guard._ShouldInline(_InliningMode))
5225  {
5226  return _M_taskCollection._RunAndWait(_PChore);
5227  }
5228  else
5229  {
5230  _M_taskCollection._Schedule(_PChore);
5231  return _NotComplete;
5232  }
5233  }
5234  }
long _Reference()
Definition: concrt.h:4042
#define _CONCRT_ASSERT(x)
Definition: concrt.h:123
_CONCRTIMP void _Schedule(_UnrealizedChore *_PChore, location *_PLocation)
Schedules a chore that can potentially run in parallel. The chore is pushed onto the associated works...
Definition: pplinterface.h:224
Definition: concrt.h:4303
_TaskCollection _M_taskCollection
Definition: concrt.h:5279
_CONCRTIMP _TaskCollectionStatus __stdcall _RunAndWait(_UnrealizedChore *_PChore=NULL)
A cancellation friendly wrapper with which to execute _PChore and then waits for all chores running i...
_AsyncTaskCollection& Concurrency::details::_AsyncTaskCollection::operator= ( const _AsyncTaskCollection )
delete

Member Data Documentation

_TaskCollection Concurrency::details::_AsyncTaskCollection::_M_taskCollection
private

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