34 template <
typename _Ty,
typename... _Whatever>
41 return ::concurrency::create_task(_M_tce);
55 _M_tce.set_exception(_Ptr);
58 ::concurrency::task_completion_event<_Ty>
_M_tce;
62 template <
typename... _Whatever>
69 return ::concurrency::create_task(_M_tce);
83 _M_tce.set_exception(_Ptr);
86 ::concurrency::task_completion_event<void>
_M_tce;
92 namespace awaitabletraitsimpl
94 template <
typename _Ty>
97 return _Obj.await_ready();
99 template <
typename _Ty>
105 template <
typename _Ty,
typename _Handle>
108 _Obj.await_suspend(_Hnd);
110 template <
typename _Ty,
typename _Handle>
116 template <
typename _Ty>
119 return _Obj.await_resume();
121 template <
typename _Ty>
127 template <
typename _Ty>
129 decltype(
_TryAwaitReady(
std::declval<std::decay_t<_Ty>>(), 0, 0),
_TryAwaitSuspend(
std::declval<std::decay_t<_Ty>>(), std::experimental::coroutine_handle<>(), 0, 0),
_TryAwaitResume(
std::declval<std::decay_t<_Ty>>(), 0, 0), 0));
139 template <
typename _Ty>
140 struct awaitable_traits :
public decltype(details::awaitabletraitsimpl::_TryAwaitable(std::declval<_Ty>(), 0))
147 template <
typename _Handle>
159 template <
typename _Ty>
162 template <
typename _Ty>
178 template <
class _Ty,
typename _Handle>
206 template <
typename _Handle>
243 template <
typename _Ty>
254 template <
typename _Handle>
260 _M_contextPtr->_M_defaultContext._CallInContext([=] {
288 template <
typename _Handle>
309 template <
typename _Ty>
322 #ifdef __cplusplus_winrt
332 return _Task->Status >= AsyncStatus::Completed;
335 template <
typename _Handle>
338 _Task->Completed =
ref new AsyncActionCompletedHandler(
339 [_ResumeCb](IAsyncAction^, AsyncStatus) { _ResumeCb(); }, ::Platform::CallbackContext::Same);
342 template <
typename _Ty,
typename _Handle>
343 void await_suspend(IAsyncOperation<_Ty>^ _Task, _Handle _ResumeCb)
345 _Task->Completed =
ref new AsyncOperationCompletedHandler<_Ty>(
346 [_ResumeCb](IAsyncOperation<_Ty>^, AsyncStatus) { _ResumeCb(); }, ::Platform::CallbackContext::Same);
349 template <
typename _Pr,
typename _Handle>
350 void await_suspend(IAsyncActionWithProgress<_Pr>^ _Task, _Handle _ResumeCb)
352 _Task->Completed =
ref new AsyncActionWithProgressCompletedHandler<_Pr>(
353 [_ResumeCb](IAsyncActionWithProgress<_Pr>^, AsyncStatus) { _ResumeCb(); }, ::Platform::CallbackContext::Same);
356 template <
typename _Ty,
typename _Pr,
typename _Handle>
357 void await_suspend(IAsyncOperationWithProgress<_Ty, _Pr>^ _Task, _Handle _ResumeCb)
359 _Task->Completed =
ref new AsyncOperationWithProgressCompletedHandler<_Ty, _Pr>(
360 [_ResumeCb](IAsyncOperationWithProgress<_Ty, _Pr>^, AsyncStatus) { _ResumeCb(); }, ::Platform::CallbackContext::Same);
365 inline void _VerifyStateForResultsCall(Windows::Foundation::AsyncStatus
status)
367 if (status == AsyncStatus::Canceled)
369 throw ::Platform::Exception::CreateException(E_ABORT);
373 inline void await_resume(Windows::Foundation::IAsyncAction^ _Task)
375 _VerifyStateForResultsCall(_Task->Status);
379 template <
typename _Ty>
380 _Ty
await_resume(Windows::Foundation::IAsyncOperation<_Ty>^ _Task)
382 _VerifyStateForResultsCall(_Task->Status);
383 return _Task->GetResults();
386 template <
typename _Pr>
387 void await_resume(Windows::Foundation::IAsyncActionWithProgress<_Pr>^ _Task)
389 _VerifyStateForResultsCall(_Task->Status);
393 template <
typename _Ty,
typename _Pr>
394 _Ty
await_resume(Windows::Foundation::IAsyncOperationWithProgress<_Ty, _Pr>^ _Task)
396 _VerifyStateForResultsCall(_Task->Status);
397 return _Task->GetResults();
402 #endif // __cplusplus_winrt
403 #endif // _PPLAWAIT_H
_Threadpool_callback _M_callback
Definition: ppltaskscheduler.h:29
auto get_return_object() const
Definition: pplawait.h:39
void await_resume()
Definition: pplawait.h:306
auto get_awaitable(_Ty _Awaitable)
Definition: pplawait.h:310
void _TryAwaitSuspend(_Ty &_Obj, _Handle _Hnd, decltype(std::declval< _Ty >().await_suspend(std::declval< _Handle >()), 0), int)
Definition: pplawait.h:106
auto get_awaitable()
Definition: pplawait.h:315
details::_ContextCallback _M_context
Definition: pplawait.h:227
reference_wrapper< _Ty > ref(_Ty &_Val) _NOEXCEPT
Definition: type_traits:1617
_CRTIMP2 void __cdecl _Release_chore(_Threadpool_chore *)
static void invoke_await_suspend(_Ty &_Obj, _Handle _Hnd)
Definition: pplawait.h:148
void return_void()
Definition: pplawait.h:76
auto await_resume(const task< _Ty > &_Task)
Definition: pplawait.h:188
auto _TryAwaitResume(_Ty &_Obj, decltype(std::declval< _Ty >().await_resume(), 0), int)
Definition: pplawait.h:117
void await_suspend(task< _Ty > &_Task, _Handle _ResumeCb)
Definition: pplawait.h:179
Definition: exception:254
await_resume_context * _M_contextPtr
Definition: pplawait.h:281
void _CallInContext(_Handle _Hnd)
Definition: pplawait.h:207
_In_ int _Val
Definition: vcruntime_string.h:62
await_resume_context * _M_contextPtr
Definition: pplawait.h:247
bool final_suspend() const
Definition: pplawait.h:74
static task_continuation_context get_current_winrt_context()
Returns a task continuation context object that represents the current winrt thread context...
Definition: ppltasks.h:955
file_status status(const path &)
Definition: filesystem:3137
auto await_resume()
Definition: pplawait.h:273
Definition: pplawait.h:279
void await_suspend(_Handle _Hnd)
Definition: pplawait.h:289
The Concurrency namespace provides classes and functions that provide access to the Concurrency Runti...
Definition: agents.h:43
bool _TryAwaitReady(_Ty &_Obj, decltype(std::declval< _Ty >().await_ready(), 0), int)
Definition: pplawait.h:95
static bool invoke_await_ready(_Ty &_Obj)
Definition: pplawait.h:142
void * _M_work
Definition: ppltaskscheduler.h:28
std::function< void()> _M_func
Definition: pplawait.h:204
_CRTIMP2 int __cdecl _Schedule_chore(_Threadpool_chore *)
integral_constant< bool, false > false_type
Definition: xtr1common:41
Definition: ppltaskscheduler.h:26
_CRTIMP2 void __thiscall _CallInContext(_CallbackFunction _Func, bool _IgnoreDisconnect) const
::concurrency::task_completion_event< void > _M_tce
Definition: pplawait.h:86
bool is_done() const
Determines if the task is completed.
Definition: ppltasks.h:3288
static auto invoke_await_resume(_Ty &_Obj)
Definition: pplawait.h:153
bool await_ready(const task< _Ty > &_Task)
Definition: pplawait.h:173
_ReturnType get() const
Returns the result this task produced. If the task is not in a terminal state, a call to get will wai...
Definition: ppltasks.h:3264
Definition: vccorlib.h:117
static await_resume_context any()
Definition: pplawait.h:238
Definition: pplawait.h:244
ThreadpoolContext()
Definition: pplawait.h:215
void set_exception(const exception_ptr &_Ptr)
Definition: pplawait.h:81
void await_suspend(_Handle _Hnd)
Definition: pplawait.h:255
~ThreadpoolContext()
Definition: pplawait.h:220
ThreadpoolContext _M_defaultContext
Definition: pplawait.h:228
static _ContextCallback _CaptureCurrent()
Definition: ppltasks.h:502
auto get_return_object() const
Definition: pplawait.h:67
::concurrency::task_completion_event< _Ty > _M_tce
Definition: pplawait.h:58
_Ty _M_awaitable
Definition: pplawait.h:246
typename awaitable_traits< _Ty >::type is_awaitable_t
Definition: pplawait.h:163
bool final_suspend() const
Definition: pplawait.h:46
std::true_type _TryAwaitable(_Ty, decltype(_TryAwaitReady(std::declval< std::decay_t< _Ty >>(), 0, 0), _TryAwaitSuspend(std::declval< std::decay_t< _Ty >>(), std::experimental::coroutine_handle<>(), 0, 0), _TryAwaitResume(std::declval< std::decay_t< _Ty >>(), 0, 0), 0))
Definition: ppltasks.h:496
_Callback(await_resume_context *_ContextPtr)
Definition: pplawait.h:284
bool initial_suspend() const
Definition: pplawait.h:72
bool await_ready()
Definition: pplawait.h:252
static await_resume_context current()
Definition: pplawait.h:231
The Parallel Patterns Library (PPL) task class. A task object represents work that can be executed as...
Definition: ppltasks.h:85
Definition: pplawait.h:196
Definition: pplawait.h:194
add_rvalue_reference< _Ty >::type declval() _NOEXCEPT
integral_constant< bool, true > true_type
Definition: xtr1common:40
details::_Threadpool_chore _M_chore
Definition: pplawait.h:198
static void __cdecl _ChoreCallback(void *_TpTask)
Definition: pplawait.h:199
bool initial_suspend() const
Definition: pplawait.h:44
void return_value(const _Ty &_Val)
Definition: pplawait.h:48
bool await_ready()
Definition: pplawait.h:286
void * _M_data
Definition: ppltaskscheduler.h:30
void set_exception(const exception_ptr &_Ptr)
Definition: pplawait.h:53
Definition: pplawait.h:140
_CallbackChain(const _Ty &_Awaitable, await_resume_context *_ContextPtr)
Definition: pplawait.h:250