Skip to content

Commit 695500f

Browse files
committed
[Win32] Initialize Windows Runtime on queue thread
1 parent 3e7c798 commit 695500f

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
144144
ShLwApi
145145
WS2_32
146146
WinMM
147-
synchronization)
147+
synchronization
148+
WindowsApp)
148149
endif()
149150

150151
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)

src/queue.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
#if HAVE_MACH
2323
#include "protocol.h" // _dispatch_send_wakeup_runloop_thread
2424
#endif
25+
#if defined(_WIN32)
26+
#include <roapi.h> // RoInitialize
27+
#endif
2528

2629
static inline void _dispatch_root_queues_init(void);
2730
static void _dispatch_lane_barrier_complete(dispatch_lane_class_t dqu,
@@ -6264,8 +6267,15 @@ _dispatch_worker_thread(void *context)
62646267
static unsigned WINAPI
62656268
_dispatch_worker_thread_thunk(LPVOID lpParameter)
62666269
{
6267-
_dispatch_worker_thread(lpParameter);
6268-
return 0;
6270+
HRESULT hr = RoInitialize(RO_INIT_MULTITHREADED);
6271+
6272+
_dispatch_worker_thread(lpParameter);
6273+
6274+
if (SUCCEEDED(hr)) {
6275+
RoUninitialize();
6276+
}
6277+
6278+
return 0;
62696279
}
62706280
#endif // defined(_WIN32)
62716281
#endif // DISPATCH_USE_PTHREAD_POOL

0 commit comments

Comments
 (0)