STLdoc
STLdocumentation
|
Task collections represent groups of work which step outside the strict structuring of the _StructuredTaskCollection definition. Any groups of work which do not follow LIFO ordering, are waited on multiple times, or are passed between arbitrary threads require utilization of this definition of a task collection. It has additional overhead over the _StructuredTaskCollection. More...
#include <concrt.h>
Public Member Functions | |
_CONCRTIMP | _TaskCollection () |
Constructs a new task collection. More... | |
_TaskCollection (const _TaskCollection &)=delete | |
_TaskCollection & | operator= (const _TaskCollection &)=delete |
_CONCRTIMP | _TaskCollection (_CancellationTokenState *_PTokenState) |
Constructs a new task collection whose cancellation is governed by the specified cancellation token state. More... | |
_CONCRTIMP | ~_TaskCollection () |
Destroys a task collection. Clients must call '_TaskCollection::_Wait' or '_TaskCollection::_RunAndWait' prior to destructing the object. If there are chores remaining in the queues, an exception (missing_wait) is thrown. If the destructor is running because of exception unwinding, it will abort any scheduled work. If another exception occurs because work is aborted, the process will terminate (C++ semantics). More... | |
_CONCRTIMP void | _Schedule (_UnrealizedChore *_PChore, location *_PLocation) |
Schedules a chore that can potentially run in parallel. 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. More... | |
_CONCRTIMP void | _Schedule (_UnrealizedChore *_PChore) |
Schedules a chore that can potentially run in parallel. 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. More... | |
_CONCRTIMP void | _Cancel () |
Cancels work on the task collection. More... | |
_CONCRTIMP bool | _IsCanceling () |
Informs the caller whether or not the task collection is currently in the midst of a cancellation. Note that this does not necessarily indicate that Cancel was called on the collection (although such certainly qualifies this function to return true). It can be the case that the task collection is executing inline and a task collection further up in the work tree was canceled. In cases such as these where we can determine ahead of time that cancellation will flow through this collection, true will be returned as well. More... | |
_CONCRTIMP _TaskCollectionStatus __stdcall | _RunAndWait (_UnrealizedChore *_PChore=NULL) |
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... | |
_TaskCollectionStatus | _Wait () |
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... | |
bool | _IsMarkedForAbnormalExit () const |
Returns whether this task collection is marked for abnormal exit. More... | |
_TaskCollection * | _OriginalCollection () const |
Returns the object which this is an alias for. More... | |
bool | _IsAlias () const |
Returns whether the task collection is an alias. More... | |
void | _RegisterCompletionHandler (TaskProc _Func, void *_PCompletionContext) |
Registers a notification handler for completion of chores More... | |
Public Member Functions inherited from Concurrency::details::_TaskCollectionBase | |
_TaskCollectionBase () | |
_TaskCollectionBase (const _TaskCollectionBase &)=delete | |
_TaskCollectionBase (_CancellationTokenState *_PTokenState) | |
_TaskCollectionBase & | operator= (const _TaskCollectionBase &)=delete |
void * | _OwningContext () const |
int | _InliningDepth () const |
bool | _IsCurrentlyInlined () const |
bool | _IsStructured () |
_CancellationTokenState * | _GetTokenState (_CancellationTokenRegistration **_PRegistration=NULL) |
Private Member Functions | |
bool | _IsStaleAlias () const |
Determines if the task collection is a stale alias (an object which was left over from a deferred delete of a direct alias but which happens to match the hash key for a newly allocated task collection) More... | |
void | _ReleaseAlias () |
Releases an alias – this will free it if the release is the last man out. More... | |
_TaskCollection (_TaskCollection *_POriginCollection, bool _FDirectAlias) | |
Constructs an alias collection based on a specified origin collection More... | |
_TaskCollection * | _Alias () |
Returns the local alias of a task collection on the current context. More... | |
void | _Abort (bool _FLeaveCanceled=false) |
Internal routine to abort work on the task collection. More... | |
bool | _IsIndirectAlias () const |
Returns whether the task collection is an indirect alias. More... | |
bool | _IsDirectAlias () const |
Returns whether the task collection is a direct alias. More... | |
bool | _HasDirectAlias () const |
Returns whether this task collection has a direct alias. More... | |
void | _Cancel (bool _InsideException, _TaskCollection *_PSnapPoint) |
Cancels work on the task collection. This is an internal version. More... | |
void | _NotifyNewChore () |
Called for every new chore put into the task collection. Assures appropriate synchronization with waiters. More... | |
void | _NotifyCompletedChoreAndFree (_UnrealizedChore *_PChore=NULL) |
Called for every completed chore from the task collection. Assures appropriate synchronization with waiters. More... | |
void | _FullAliasWait (_TaskCollection *_PSnapPoint) |
Waits on the given task collection and every alias. More... | |
void | _Reset (_TaskCollection *_PSnapPoint) |
Resets the task collection for future usage. More... | |
void | _RaisedException () |
Called when an exception is raised on a chore on an unstructured task collection, this makes a determination of what to do with the exception and saves it for potential transport back to the thread performing a join on a task collection. This specifically handles situations on for unstructured task collections before calling _TaskCollectionBase::_RaisedException. More... | |
void | _RaisedCancel () |
Called when a cancellation is raised on a chore on a given task collection. This makes a determination of what to do with the exception and saves it for potential transport back to the thread performing a join on a chore collection. Note that every other exception has precedence over a cancellation. More... | |
bool | _SetCancelState (long _Status) |
Called in order to set the cancellation status of the collection. More... | |
void | _CancelFromArbitraryThread (bool _InsideException) |
Called to cancel a single alias of a task collection from an arbitrary thread. More... | |
void | _CancelDirectAliases (bool _InsideException, _TaskCollection *_PSnapPoint) |
Cancels all direct aliases of the task collection. More... | |
void | _CancelStolenContexts (bool _InsideException, bool _FInlineGated) |
Called to cancel any contexts which stole chores from the given collection. This is PART of a cancellation scheme. The remainder must be handled by the derived class in particular. This should be called last. More... | |
void * | _GetStealTrackingList () const |
Returns the steal tracking list. More... | |
void | _Initialize () |
Internal initialization of the task collection More... | |
void | _AbortiveSweep (void *_PCtx) |
Performs an abortive sweep of the WSQ for inline stack overflow. More... | |
bool | _TaskCleanup (bool _FExceptional) |
Performs task cleanup normally done at destruction time. More... | |
Static Private Member Functions | |
static bool __cdecl | _CollectionMatchPredicate (_UnrealizedChore *_PChore, void *_PData) |
A predicate function checking whether a given chore belongs to a given collection. More... | |
static bool __cdecl | _SweepAbortedChore (_UnrealizedChore *_PChore, void *_PData) |
Called to sweep an aborted chore in the case of inline stack overflow. More... | |
static void __cdecl | _CancelViaToken (_TaskCollection *_PCollection) |
Called when the task collection is canceled via a cancellation token. More... | |
Private Attributes | |
_CONCRT_BUFFER | _M_stealTracker [_SAFERWLIST_SIZE] |
Tracks contexts that have stolen chores from this collection. This is storage for an internal list and lock. Note that this list is only used for detached schedule groups. More... | |
long | _M_activeStealersForCancellation |
A count of active stealers for CANCELLATION PURPOSES ONLY. This is non-interlocked and guarded by the same lock as the stealers list on this task collection. More... | |
volatile long | _M_exitCode |
An indication of the exit code of the chore. Anything non-zero here indicates cancellation of one form or another. More... | |
volatile long | _M_executionStatus |
The status of the task collection. More... | |
event | _M_event |
An event on which to wait for stolen chores to complete. More... | |
_TaskCollection * | _M_pOriginalCollection |
_TaskCollection * | _M_pNextAlias |
void * | _M_pTaskExtension |
int | _M_taskCookies [2] |
volatile long | _M_flags |
volatile long | _M_chaining |
DWORD | _M_boundQueueId |
int | _M_stackPos |
TaskProc | _M_completionHandler |
void * | _M_pCompletionContext |
Friends | |
class | _UnrealizedChore |
class | ::Concurrency::details::ContextBase |
Task collections represent groups of work which step outside the strict structuring of the _StructuredTaskCollection definition. Any groups of work which do not follow LIFO ordering, are waited on multiple times, or are passed between arbitrary threads require utilization of this definition of a task collection. It has additional overhead over the _StructuredTaskCollection.
_CONCRTIMP Concurrency::details::_TaskCollection::_TaskCollection | ( | ) |
Constructs a new task collection.
|
delete |
_CONCRTIMP Concurrency::details::_TaskCollection::_TaskCollection | ( | _CancellationTokenState * | _PTokenState | ) |
Constructs a new task collection whose cancellation is governed by the specified cancellation token state.
_PTokenState | When this cancellation token is canceled, the task collection is canceled. |
_CONCRTIMP Concurrency::details::_TaskCollection::~_TaskCollection | ( | ) |
Destroys a task collection. Clients must call '_TaskCollection::_Wait' or '_TaskCollection::_RunAndWait' prior to destructing the object. If there are chores remaining in the queues, an exception (missing_wait) is thrown. If the destructor is running because of exception unwinding, it will abort any scheduled work. If another exception occurs because work is aborted, the process will terminate (C++ semantics).
|
private |
Constructs an alias collection based on a specified origin collection
_POriginCollection | Specifies which collection the newly constructed one will alias |
_FDirectAlias | Specifies whether the newly constructed collection is a direct alias |
Internal routine to abort work on the task collection.
_FLeaveCanceled | An indication as to whether or not to leave the task collection canceled after the abort. |
Performs an abortive sweep of the WSQ for inline stack overflow.
_PCtx | The context to sweep |
|
private |
Returns the local alias of a task collection on the current context.
_CONCRTIMP void Concurrency::details::_TaskCollection::_Cancel | ( | ) |
Cancels work on the task collection.
|
private |
Cancels work on the task collection. This is an internal version.
_InsideException | Indicates whether the cancellation is taking place because of exception unwinding within the runtime |
_PSnapPoint | A snapshot of the direct alias list which is what the call will effect |
|
private |
Cancels all direct aliases of the task collection.
_InsideException | Indicates whether the cancellation is taking place because of exception unwinding within the runtime |
_PSnapPoint | A snapshot of the direct alias list which is what the call will effect |
|
private |
Called to cancel a single alias of a task collection from an arbitrary thread.
_InsideException | Indicates whether the cancellation is taking place because of exception unwinding within the runtime |
|
private |
Called to cancel any contexts which stole chores from the given collection. This is PART of a cancellation scheme. The remainder must be handled by the derived class in particular. This should be called last.
_InsideException | Indicates whether the cancellation is taking place because of exception unwinding within the runtime |
_FInlineGated | Indicates whether the inline context is safe and blocked from becoming inaccessible during the duration of the call |
|
staticprivate |
Called when the task collection is canceled via a cancellation token.
|
staticprivate |
A predicate function checking whether a given chore belongs to a given collection.
_PChore | The chore to check |
_PData | The data to check against |
|
private |
Waits on the given task collection and every alias.
_PSnapPoint | A snapshot of the direct alias list which is what the call will effect |
|
private |
Returns the steal tracking list.
|
private |
Returns whether this task collection has a direct alias.
|
private |
Internal initialization of the task collection
bool Concurrency::details::_TaskCollection::_IsAlias | ( | ) | const |
Returns whether the task collection is an alias.
_CONCRTIMP bool Concurrency::details::_TaskCollection::_IsCanceling | ( | ) |
Informs the caller whether or not the task collection is currently in the midst of a cancellation. Note that this does not necessarily indicate that Cancel was called on the collection (although such certainly qualifies this function to return true). It can be the case that the task collection is executing inline and a task collection further up in the work tree was canceled. In cases such as these where we can determine ahead of time that cancellation will flow through this collection, true will be returned as well.
|
private |
Returns whether the task collection is a direct alias.
|
private |
Returns whether the task collection is an indirect alias.
bool Concurrency::details::_TaskCollection::_IsMarkedForAbnormalExit | ( | ) | const |
Returns whether this task collection is marked for abnormal exit.
|
private |
Determines if the task collection is a stale alias (an object which was left over from a deferred delete of a direct alias but which happens to match the hash key for a newly allocated task collection)
|
private |
Called for every completed chore from the task collection. Assures appropriate synchronization with waiters.
_PChore | An _UnrealizedChore which will be freed if its lifetime is owned by the Runtime. |
|
private |
Called for every new chore put into the task collection. Assures appropriate synchronization with waiters.
_TaskCollection* Concurrency::details::_TaskCollection::_OriginalCollection | ( | ) | const |
Returns the object which this is an alias for.
|
private |
Called when a cancellation is raised on a chore on a given task collection. This makes a determination of what to do with the exception and saves it for potential transport back to the thread performing a join on a chore collection. Note that every other exception has precedence over a cancellation.
|
private |
Called when an exception is raised on a chore on an unstructured task collection, this makes a determination of what to do with the exception and saves it for potential transport back to the thread performing a join on a task collection. This specifically handles situations on for unstructured task collections before calling _TaskCollectionBase::_RaisedException.
void Concurrency::details::_TaskCollection::_RegisterCompletionHandler | ( | TaskProc | _Func, |
void * | _PCompletionContext | ||
) |
Registers a notification handler for completion of chores
_Func | The callback function |
_PCompletionContext | The completion context for the callback function |
|
private |
Releases an alias – this will free it if the release is the last man out.
|
private |
Resets the task collection for future usage.
_PSnapPoint | A snapshot of the direct alias list which is what the call will effect |
_CONCRTIMP _TaskCollectionStatus __stdcall Concurrency::details::_TaskCollection::_RunAndWait | ( | _UnrealizedChore * | _PChore = NULL | ) |
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.
_PChore | An _UnrealizedChore which when non-null will be called to invoke the chore in a cancellation friendly manner. |
_CONCRTIMP void Concurrency::details::_TaskCollection::_Schedule | ( | _UnrealizedChore * | _PChore, |
location * | _PLocation | ||
) |
Schedules a chore that can potentially run in parallel. 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.
_PChore | The new unrealized chore to schedule |
_PLocation | The location where the unrealized chore should execute. Specifying the value NULL here indicates that the unrealized chore does not have specific placement. |
_CONCRTIMP void Concurrency::details::_TaskCollection::_Schedule | ( | _UnrealizedChore * | _PChore | ) |
Schedules a chore that can potentially run in parallel. 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.
_PChore | The new unrealized chore to schedule |
|
private |
Called in order to set the cancellation status of the collection.
_Status | The cancellation status to set |
|
staticprivate |
Called to sweep an aborted chore in the case of inline stack overflow.
_PChore | The chore to sweep |
_PData | The data that was passed to the sweep predicate |
Performs task cleanup normally done at destruction time.
_FExceptional | An indication if the cleanup is exceptional and the collection should be left in a canceled state. |
|
inline |
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.
|
delete |
|
friend |
|
friend |
|
private |
A count of active stealers for CANCELLATION PURPOSES ONLY. This is non-interlocked and guarded by the same lock as the stealers list on this task collection.
|
private |
|
private |
|
private |
|
private |
An event on which to wait for stolen chores to complete.
|
private |
The status of the task collection.
|
private |
An indication of the exit code of the chore. Anything non-zero here indicates cancellation of one form or another.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Tracks contexts that have stolen chores from this collection. This is storage for an internal list and lock. Note that this list is only used for detached schedule groups.
|
private |