1717#pragma warning(pop)
1818#endif
1919#include < ctxtcall.h>
20- #include < mutex>
20+ #include < functional>
21+ #include < stdexcept>
2122#include < windows.foundation.diagnostics.h>
2223#endif
2324
24- // This IID is exported by ole32.dll; we cannot depend on ole32.dll.
25- static GUID const Local_IID_ICallbackWithNoReentrancyToApplicationSTA = {
26- 0x0A299774 , 0x3E4E , 0xFC42 , {0x1D , 0x9D , 0x72 , 0xCE , 0xE1 , 0x05 , 0xCA , 0x57 }};
27-
28- // Introduce stacktrace API for Debug CRT_APP
29- #if defined(_CRT_APP) && defined(_DEBUG)
30- extern " C" NTSYSAPI _Success_ (return != 0 ) WORD NTAPI
31- RtlCaptureStackBackTrace(_In_ DWORD FramesToSkip, _In_ DWORD FramesToCapture,
32- _Out_writes_to_ (FramesToCapture, return ) PVOID* BackTrace, _Out_opt_ PDWORD BackTraceHash);
33- #endif
34-
3525namespace Concurrency {
3626
3727 namespace details {
@@ -55,27 +45,13 @@ namespace Concurrency {
5545 // / CRT CaptureStackBackTrace API wrapper
5646 // / </summary>
5747 _CRTIMP2 size_t __cdecl CaptureCallstack (void ** stackData, size_t skipFrames, size_t captureFrames) {
58- size_t capturedFrames = 0 ;
59- // RtlCaptureStackBackTrace is not available in MSDK, so we only call it under Desktop or _DEBUG MSDK.
60- // For MSDK unsupported version, we will return zero frame number.
61- #if !defined(_CRT_APP) || defined(_DEBUG)
62- capturedFrames = RtlCaptureStackBackTrace (
48+ return RtlCaptureStackBackTrace (
6349 static_cast <DWORD>(skipFrames + 1 ), static_cast <DWORD>(captureFrames), stackData, nullptr );
64- #else
65- (stackData);
66- (skipFrames);
67- (captureFrames);
68- #endif
69- return capturedFrames;
7050 }
7151
7252 static unsigned int s_asyncId = 0 ;
7353
7454 _CRTIMP2 unsigned int __cdecl GetNextAsyncId () {
75- //
76- // ASYNC TODO: Determine the requirements on the domain uniqueness of this value. C++ / C# / WRL are
77- // all supposed to produce "unique" IDs and there is no common broker.
78- //
7955 return static_cast <unsigned int >(::_InterlockedIncrement (reinterpret_cast <volatile LONG*>(&s_asyncId)));
8056 }
8157
@@ -99,6 +75,10 @@ namespace Concurrency {
9975 using namespace Microsoft ::WRL;
10076 using namespace Microsoft ::WRL::Wrappers;
10177
78+ // This IID is exported by ole32.dll; we cannot depend on ole32.dll.
79+ static GUID const Local_IID_ICallbackWithNoReentrancyToApplicationSTA = {
80+ 0x0A299774 , 0x3E4E , 0xFC42 , {0x1D , 0x9D , 0x72 , 0xCE , 0xE1 , 0x05 , 0xCA , 0x57 }};
81+
10282 static HRESULT __stdcall _PPLTaskContextCallbackBridge (ComCallData* _PParam) {
10383 auto pFunc = static_cast <std::function<void ()>*>(_PParam->pUserDefined );
10484 (*pFunc)();
0 commit comments