18 #ifndef _PPLINTERFACE_H
19 #define _PPLINTERFACE_H
22 #elif defined(_MS_WINDOWS)
23 #if (_MSC_VER >= 1700)
24 #define _USE_REAL_ATOMICS
27 #define _USE_REAL_ATOMICS
31 #ifdef _USE_REAL_ATOMICS
48 struct __declspec(novtable) scheduler_interface
50 virtual void schedule(
TaskProc_t,
void* ) = 0;
86 scheduler_interface *
get()
const
94 operator bool()
const {
return get() !=
nullptr; }
141 #ifdef _USE_REAL_ATOMICS
145 template<
typename _T>
148 _T _Result = _Comparand;
149 _Target.compare_exchange_strong(_Result, _Exchange);
153 template<
typename _T>
156 return _Target.exchange(_Value);
159 template<
typename _T>
162 return _Target.fetch_add(1) + 1;
165 template<
typename _T>
168 return _Target.fetch_sub(1) - 1;
171 template<
typename _T>
174 return _Target.fetch_add(value) + value;
177 #else // not _USE_REAL_ATOMICS
185 return _InterlockedExchange(&_Target, _Value);
193 inline long atomic_add(
long volatile & _Target,
long value)
195 return _InterlockedExchangeAdd(&_Target, value) + value;
200 #if (defined(_M_IX86) || defined(_M_ARM))
203 return static_cast<size_t>(_InterlockedIncrement64(reinterpret_cast<__int64 volatile *>(&_Target)));
214 #if (defined(_M_IX86) || defined(_M_ARM))
217 return static_cast<size_t>(_InterlockedDecrement64(reinterpret_cast<__int64 volatile *>(&_Target)));
228 #if (defined(_M_IX86) || defined(_M_ARM))
229 return static_cast<size_t>(
_InterlockedCompareExchange(reinterpret_cast<long volatile *>(_Target), static_cast<long>(_Exchange), static_cast<long>(_Comparand)));
231 return static_cast<size_t>(_InterlockedCompareExchange64(reinterpret_cast<__int64 volatile *>(_Target), static_cast<__int64>(_Exchange), static_cast<__int64>(_Comparand)));
234 #endif // _USE_REAL_ATOMICS
238 #endif // _PPLINTERFACE_H
_T atomic_exchange(std::atomic< _T > &_Target, _T _Value)
Definition: pplinterface.h:154
_CRTIMP _In_ int _Value
Definition: setjmp.h:190
_T atomic_compare_exchange(std::atomic< _T > &_Target, _T _Exchange, _T _Comparand)
Definition: pplinterface.h:146
std::atomic< size_t > atomic_size_t
Definition: pplinterface.h:143
_OutIt move(_InIt _First, _InIt _Last, _OutIt _Dest)
Definition: xutility:2447
scheduler_interface * operator->() const
Behave like a pointer
Definition: pplinterface.h:78
typedef void(__cdecl *_se_translator_function)(unsigned int
The Concurrency namespace provides classes and functions that provide access to the Concurrency Runti...
Definition: agents.h:42
The tasks queued to the task_group object have not completed. Note that this value is not presently r...
Definition: pplinterface.h:121
_T atomic_decrement(std::atomic< _T > &_Target)
Definition: pplinterface.h:166
scheduler_interface * m_scheduler
Definition: pplinterface.h:99
#define _In_opt_
Definition: sal.h:315
#define bool
Definition: stdbool.h:10
The tasks queued to the task_group or structured_task_group object completed successfully.
Definition: pplinterface.h:127
The task_group or structured_task_group object was canceled. One or more tasks may not have executed...
Definition: pplinterface.h:133
scheduler_ptr(_In_opt_ scheduler_interface *pScheduler)
Creates a scheduler pointer from raw pointer to scheduler
Definition: pplinterface.h:71
Represents a pointer to a scheduler. This class exists to allow the the specification of a shared lif...
Definition: pplinterface.h:58
_T atomic_add(std::atomic< _T > &_Target, _T value)
Definition: pplinterface.h:172
scheduler_ptr(std::shared_ptr< scheduler_interface > scheduler)
Creates a scheduler pointer from shared_ptr to scheduler
Definition: pplinterface.h:63
void(__cdecl * TaskProc_t)(void *)
An elementary abstraction for a task, defined as void (__cdecl * TaskProc_t)(void *)...
Definition: pplinterface.h:43
std::shared_ptr< scheduler_interface > m_sharedScheduler
Definition: pplinterface.h:98
_T atomic_increment(std::atomic< _T > &_Target)
Definition: pplinterface.h:160
#define _T(x)
Definition: tchar.h:2498
task_group_status
Describes the execution status of a task_group or structured_task_group object. A value of this type ...
Definition: pplinterface.h:114
long __cdecl _InterlockedDecrement(long volatile *)
std::atomic< long > atomic_long
Atomics
Definition: pplinterface.h:142
long __cdecl _InterlockedIncrement(long volatile *)
long __cdecl _InterlockedCompareExchange(long volatile *, long, long)