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

#include <pplconcrt.h>

Public Types

typedef Concurrency::details::_TaskProcHandle _TaskProcHandle_t
 

Public Member Functions

 _TaskCollectionImpl (::Concurrency::scheduler_ptr _PScheduler)
 
 ~_TaskCollectionImpl ()
 
void _ScheduleTask (_TaskProcHandle_t *_Parameter, _TaskInliningMode _InliningMode)
 
void _Cancel ()
 
void _RunAndWait ()
 
void _Wait ()
 
void _Complete ()
 
::Concurrency::scheduler_ptr _GetScheduler () const
 

Static Public Member Functions

static void _RunTask (TaskProc _Proc, void *_Parameter, _TaskInliningMode _InliningMode)
 
static bool __cdecl _Is_cancellation_requested ()
 

Private Member Functions

void _SetScheduled ()
 

Private Attributes

::Concurrency::extensibility::event_t _M_Scheduled
 
::Concurrency::extensibility::event_t _M_Completed
 
_AsyncTaskCollection_M_pTaskCollection
 
::Concurrency::scheduler_ptr _M_pScheduler
 

Member Typedef Documentation

Constructor & Destructor Documentation

Concurrency::details::_TaskCollectionImpl::_TaskCollectionImpl ( ::Concurrency::scheduler_ptr  _PScheduler)
inline
136  : _M_pTaskCollection(nullptr), _M_pScheduler(_PScheduler)
137  {
138  }
_AsyncTaskCollection * _M_pTaskCollection
Definition: pplconcrt.h:266
::Concurrency::scheduler_ptr _M_pScheduler
Definition: pplconcrt.h:267
Concurrency::details::_TaskCollectionImpl::~_TaskCollectionImpl ( )
inline
141  {
142  if (_M_pTaskCollection != nullptr)
143  {
145  _M_pTaskCollection = nullptr;
146  }
147  }
_AsyncTaskCollection * _M_pTaskCollection
Definition: pplconcrt.h:266
long _Release()
Definition: concrt.h:4180

Member Function Documentation

void Concurrency::details::_TaskCollectionImpl::_Cancel ( )
inline
192  {
193  // Ensure that RunAndWait makes progress.
194  _SetScheduled();
195 
196  if (_M_pTaskCollection != nullptr)
197  {
199  }
200  }
_AsyncTaskCollection * _M_pTaskCollection
Definition: pplconcrt.h:266
void _Cancel()
Cancels work on the task collection.
Definition: concrt.h:5381
void _SetScheduled()
Definition: pplconcrt.h:259
void Concurrency::details::_TaskCollectionImpl::_Complete ( )
inline
225  {
226  // Ensure that RunAndWait makes progress.
227  _SetScheduled();
228  _M_Completed.set();
229  }
_CRTIMP void set()
Signals the event.
::Concurrency::extensibility::event_t _M_Completed
Definition: pplconcrt.h:265
void _SetScheduled()
Definition: pplconcrt.h:259
::Concurrency::scheduler_ptr Concurrency::details::_TaskCollectionImpl::_GetScheduler ( ) const
inline
232  {
233  return _M_pScheduler;
234  }
::Concurrency::scheduler_ptr _M_pScheduler
Definition: pplconcrt.h:267
static bool __cdecl Concurrency::details::_TaskCollectionImpl::_Is_cancellation_requested ( )
inlinestatic
253  {
254  // ConcRT scheduler under the hood is using TaskCollection, which is same as task_group
256  }
_CRTIMP2 bool __cdecl is_current_task_group_canceling()
Returns an indication of whether the task group which is currently executing inline on the current co...
void Concurrency::details::_TaskCollectionImpl::_RunAndWait ( )
inline
203  {
204  _M_Scheduled.wait();
205 
206  if (_M_pTaskCollection != nullptr)
207  {
208  // When it returns cancelled, either work chore or the cancel thread should already have set task's state
209  // properly -- cancelled state or completed state (because there was no interruption point).
210  // For tasks with unwrapped tasks, we should not change the state of current task, since the unwrapped task are still running.
212  }
213  else
214  {
215  _M_Completed.wait();
216  }
217  }
_AsyncTaskCollection * _M_pTaskCollection
Definition: pplconcrt.h:266
_CRTIMP size_t wait(unsigned int _Timeout=COOPERATIVE_TIMEOUT_INFINITE)
Waits for the event to become signaled.
_TaskCollectionStatus _RunAndWait()
A cancellation friendly wrapper with which to execute _PChore and then waits for all chores running i...
Definition: concrt.h:5399
::Concurrency::extensibility::event_t _M_Completed
Definition: pplconcrt.h:265
::Concurrency::extensibility::event_t _M_Scheduled
Definition: pplconcrt.h:264
static void Concurrency::details::_TaskCollectionImpl::_RunTask ( TaskProc  _Proc,
void _Parameter,
_TaskInliningMode  _InliningMode 
)
inlinestatic
238  {
240 
241  if (_Guard._ShouldInline(_InliningMode))
242  {
243  _Proc(_Parameter);
244  }
245  else
246  {
247  // Schedule the work on the current scheduler
248  _CurrentScheduler::_ScheduleTask(_Proc, _Parameter);
249  }
250  }
bool _ShouldInline(_TaskInliningMode _InliningMode) const
Definition: concrt.h:5298
static _CRTIMP void __cdecl _ScheduleTask(TaskProc _Proc, void *_Data)
RAII wrapper used to maintain and limit ppltask maximum inline schedule depth. This class will keep a...
Definition: concrt.h:5284
void Concurrency::details::_TaskCollectionImpl::_ScheduleTask ( _TaskProcHandle_t _Parameter,
_TaskInliningMode  _InliningMode 
)
inline
150  {
151  if (!_M_pScheduler)
152  {
153  // Construct the task collection; We use none token to provent it becoming interruption point.
155  }
156 
157  try
158  {
159  if (_M_pTaskCollection != nullptr)
160  {
161  // Do not need to check its returning state, more details please refer to _Wait method.
162  auto _PChore = static_cast< ::Concurrency::details::_UnrealizedChore*>(_Parameter);
163  _M_pTaskCollection->_ScheduleWithAutoInline(_PChore, _InliningMode);
164  }
165  else
166  {
167  // Schedule the work on the user provided scheduler
168  if (_InliningMode == _ForceInline)
169  {
171  }
172  else
173  {
174  _M_pScheduler->schedule(_TaskProcHandle_t::_RunChoreBridge, _Parameter);
175  }
176  }
177  }
178  catch(...)
179  {
180  _SetScheduled();
181  throw;
182  }
183 
184  // Set the event in case anyone is waiting to notify that this task has been scheduled. In the case where we
185  // execute the chore inline, the event should be set after the chore has executed, to prevent a different thread
186  // performing a wait on the task from waiting on the task collection before the chore is actually added to it,
187  // and thereby returning from the wait() before the chore has executed.
188  _SetScheduled();
189  }
_AsyncTaskCollection * _M_pTaskCollection
Definition: pplconcrt.h:266
Definition: concrt.h:5277
_TaskCollectionStatus _ScheduleWithAutoInline(_UnrealizedChore *_PChore, _TaskInliningMode _InliningMode)
Schedule a chore with automatic inlining. The chore is pushed onto the associated workstealing queue...
Definition: concrt.h:5353
::Concurrency::scheduler_ptr _M_pScheduler
Definition: pplconcrt.h:267
static _CancellationTokenState * _None()
Definition: pplcancellation_token.h:328
static _CRTIMP _AsyncTaskCollection *__cdecl _NewCollection(_CancellationTokenState *_PTokenState)
Constructs a new task collection whose cancellation is governed by the specified cancellation token s...
void _SetScheduled()
Definition: pplconcrt.h:259
static void __cdecl _RunChoreBridge(void *_Parameter)
Definition: pplconcrt.h:113
void Concurrency::details::_TaskCollectionImpl::_SetScheduled ( )
inlineprivate
260  {
261  _M_Scheduled.set();
262  }
_CRTIMP void set()
Signals the event.
::Concurrency::extensibility::event_t _M_Scheduled
Definition: pplconcrt.h:264
void Concurrency::details::_TaskCollectionImpl::_Wait ( )
inline
220  {
221  _M_Completed.wait();
222  }
_CRTIMP size_t wait(unsigned int _Timeout=COOPERATIVE_TIMEOUT_INFINITE)
Waits for the event to become signaled.
::Concurrency::extensibility::event_t _M_Completed
Definition: pplconcrt.h:265

Member Data Documentation

::Concurrency::extensibility::event_t Concurrency::details::_TaskCollectionImpl::_M_Completed
private
::Concurrency::scheduler_ptr Concurrency::details::_TaskCollectionImpl::_M_pScheduler
private
_AsyncTaskCollection* Concurrency::details::_TaskCollectionImpl::_M_pTaskCollection
private
::Concurrency::extensibility::event_t Concurrency::details::_TaskCollectionImpl::_M_Scheduled
private

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