17
17
#pragma warning(pop)
18
18
#endif
19
19
#include < ctxtcall.h>
20
- #include < mutex>
20
+ #include < functional>
21
+ #include < stdexcept>
21
22
#include < windows.foundation.diagnostics.h>
22
23
#endif
23
24
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
-
35
25
namespace Concurrency {
36
26
37
27
namespace details {
@@ -55,27 +45,13 @@ namespace Concurrency {
55
45
// / CRT CaptureStackBackTrace API wrapper
56
46
// / </summary>
57
47
_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 (
63
49
static_cast <DWORD>(skipFrames + 1 ), static_cast <DWORD>(captureFrames), stackData, nullptr );
64
- #else
65
- (stackData);
66
- (skipFrames);
67
- (captureFrames);
68
- #endif
69
- return capturedFrames;
70
50
}
71
51
72
52
static unsigned int s_asyncId = 0 ;
73
53
74
54
_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
- //
79
55
return static_cast <unsigned int >(::_InterlockedIncrement (reinterpret_cast <volatile LONG*>(&s_asyncId)));
80
56
}
81
57
@@ -99,6 +75,10 @@ namespace Concurrency {
99
75
using namespace Microsoft ::WRL;
100
76
using namespace Microsoft ::WRL::Wrappers;
101
77
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
+
102
82
static HRESULT __stdcall _PPLTaskContextCallbackBridge (ComCallData* _PParam) {
103
83
auto pFunc = static_cast <std::function<void ()>*>(_PParam->pUserDefined );
104
84
(*pFunc)();
0 commit comments