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

_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 _CRTIMP _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 _CRTIMP 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 ( _CancellationTokenState _PTokenState)
private

Member Function Documentation

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

Cancels work on the task collection.

5382  {
5384  }
_CRTIMP void _Cancel()
Cancels work on the task collection.
_TaskCollection _M_taskCollection
Definition: concrt.h:5421
virtual _CRTIMP void Concurrency::details::_AsyncTaskCollection::_Destroy ( )
privatevirtual
static _CRTIMP _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.
5400  {
5401  // Note that _Guard is NOT unused variable, the constructor and destructor will be called to maintain inline depth.
5402  _StackGuard _Guard;
5403  return _M_taskCollection._RunAndWait();
5404  }
_CRTIMP _TaskCollectionStatus __stdcall _RunAndWait(_UnrealizedChore *_PChore=NULL)
A cancellation friendly wrapper with which to execute _PChore and then waits for all chores running i...
_TaskCollection _M_taskCollection
Definition: concrt.h:5421
_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.
5354  {
5355  _CONCRT_ASSERT(_PChore);
5356  _Reference();
5357 
5358  if (_InliningMode == _NoInline)
5359  {
5360  _M_taskCollection._Schedule(_PChore);
5361  return _NotComplete;
5362  }
5363  else
5364  {
5365  _StackGuard _Guard;
5366  if (_Guard._ShouldInline(_InliningMode))
5367  {
5368  return _M_taskCollection._RunAndWait(_PChore);
5369  }
5370  else
5371  {
5372  _M_taskCollection._Schedule(_PChore);
5373  return _NotComplete;
5374  }
5375  }
5376  }
long _Reference()
Definition: concrt.h:4169
#define _CONCRT_ASSERT(x)
Definition: concrt.h:137
_CRTIMP void _Schedule(_UnrealizedChore *_PChore, location *_PLocation)
Schedules a chore that can potentially run in parallel. The chore is pushed onto the associated works...
Definition: concrt.h:5273
_CRTIMP _TaskCollectionStatus __stdcall _RunAndWait(_UnrealizedChore *_PChore=NULL)
A cancellation friendly wrapper with which to execute _PChore and then waits for all chores running i...
Definition: concrt.h:4425
_TaskCollection _M_taskCollection
Definition: concrt.h:5421

Member Data Documentation

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

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