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

#include <pplwin.h>

Public Types

typedef _TaskProcHandle _TaskProcHandle_t
 

Public Member Functions

 _TaskCollectionBaseImpl (::Concurrency::scheduler_ptr _PScheduler)
 
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_t _Proc, void *_Parameter, _TaskInliningMode _InliningMode)
 

Protected Types

enum  _TaskCollectionState { _New, _Scheduled, _Completed }
 

Protected Member Functions

void _SetCollectionState (_TaskCollectionState _NewState)
 
void WaitUntilStateChangedTo (_TaskCollectionState _State)
 

Protected Attributes

::std::condition_variable _M_StateChanged
 
::std::mutex _M_Cs
 
::Concurrency::scheduler_ptr _M_pScheduler
 
_TaskCollectionState _M_State
 

Member Typedef Documentation

Member Enumeration Documentation

Enumerator
_New 
_Scheduled 
_Completed 

Constructor & Destructor Documentation

Concurrency::details::_TaskCollectionBaseImpl::_TaskCollectionBaseImpl ( ::Concurrency::scheduler_ptr  _PScheduler)
inline
185  : _M_pScheduler(_PScheduler), _M_State(_New)
186  {
187  }
_TaskCollectionState _M_State
Definition: pplwin.h:259
::Concurrency::scheduler_ptr _M_pScheduler
Definition: pplwin.h:258

Member Function Documentation

void Concurrency::details::_TaskCollectionBaseImpl::_Cancel ( )
inline
209  {
210  // No cancellation support
211  }
void Concurrency::details::_TaskCollectionBaseImpl::_Complete ( )
inline
224  {
225  // Ensure that RunAndWait makes progress.
227  }
void _SetCollectionState(_TaskCollectionState _NewState)
Definition: pplwin.h:159
::Concurrency::scheduler_ptr Concurrency::details::_TaskCollectionBaseImpl::_GetScheduler ( ) const
inline
230  {
231  return _M_pScheduler;
232  }
::Concurrency::scheduler_ptr _M_pScheduler
Definition: pplwin.h:258
void Concurrency::details::_TaskCollectionBaseImpl::_RunAndWait ( )
inline
214  {
215  _Wait();
216  }
void _Wait()
Definition: pplwin.h:218
static void Concurrency::details::_TaskCollectionBaseImpl::_RunTask ( TaskProc_t  _Proc,
void _Parameter,
_TaskInliningMode  _InliningMode 
)
inlinestatic
236  {
237  if (_InliningMode == _ForceInline)
238  {
239  _Proc(_Parameter);
240  }
241  else
242  {
243  // Schedule the work on the default scheduler if the ambient scheduler is not set
244  auto _Ptr = get_ambient_scheduler();
245  if (_Ptr)
246  {
247  _Ptr->schedule(_Proc, _Parameter);
248  }
249  else
250  {
251  _DefaultPPLTaskScheduler().schedule(_Proc, _Parameter);
252  }
253  }
254  }
Definition: pplinterface.h:228
const ::std::shared_ptr< scheduler_interface > & get_ambient_scheduler()
Definition: pplwin.h:88
void Concurrency::details::_TaskCollectionBaseImpl::_ScheduleTask ( _TaskProcHandle_t _Parameter,
_TaskInliningMode  _InliningMode 
)
inline
190  {
191  if (_InliningMode == _ForceInline)
192  {
194  }
195  else
196  {
197  if (_M_pScheduler)
198  {
199  _M_pScheduler->schedule(_TaskProcHandle_t::_RunChoreBridge, _Parameter);
200  }
201  else
202  {
203  _DefaultPPLTaskScheduler().schedule(_TaskProcHandle_t::_RunChoreBridge, _Parameter);
204  }
205  }
206  }
Definition: pplinterface.h:228
::Concurrency::scheduler_ptr _M_pScheduler
Definition: pplwin.h:258
static void __cdecl _RunChoreBridge(void *_Parameter)
Definition: pplwin.h:144
void Concurrency::details::_TaskCollectionBaseImpl::_SetCollectionState ( _TaskCollectionState  _NewState)
inlineprotected
160  {
161  _ASSERTE(_NewState != _New);
162  std::lock_guard<std::mutex> _Lock(_M_Cs);
163  if (_M_State < _NewState)
164  {
165  _M_State = _NewState;
166  }
167 
168  _M_StateChanged.notify_all();
169  }
_TaskCollectionState _M_State
Definition: pplwin.h:259
#define _ASSERTE(expr)
Definition: crtdbg.h:707
::std::mutex _M_Cs
Definition: pplwin.h:257
::std::condition_variable _M_StateChanged
Definition: pplwin.h:256
void Concurrency::details::_TaskCollectionBaseImpl::_Wait ( )
inline
219  {
221  }
void WaitUntilStateChangedTo(_TaskCollectionState _State)
Definition: pplwin.h:171
void Concurrency::details::_TaskCollectionBaseImpl::WaitUntilStateChangedTo ( _TaskCollectionState  _State)
inlineprotected
172  {
173  std::unique_lock<std::mutex> _Lock(_M_Cs);
174 
175  while(_M_State < _State)
176  {
177  _M_StateChanged.wait(_Lock);
178  }
179  }
_TaskCollectionState _M_State
Definition: pplwin.h:259
_In_ size_t _Deref_pre_opt_z_ char const _In_ size_t _Inout_ mbstate_t * _State
Definition: wchar.h:78
::std::mutex _M_Cs
Definition: pplwin.h:257
::std::condition_variable _M_StateChanged
Definition: pplwin.h:256

Member Data Documentation

::std::mutex Concurrency::details::_TaskCollectionBaseImpl::_M_Cs
protected
::Concurrency::scheduler_ptr Concurrency::details::_TaskCollectionBaseImpl::_M_pScheduler
protected
_TaskCollectionState Concurrency::details::_TaskCollectionBaseImpl::_M_State
protected
::std::condition_variable Concurrency::details::_TaskCollectionBaseImpl::_M_StateChanged
protected

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