Skip to content

Commit a066a6e

Browse files
committed
Concurrency: support newer dispatch functionality on Windows
This addresses an unintended instance where new dispatch functionality is not used on Windows as the lookup was never performed. This limits the runtime to shared linking which should generally be a safe assumption on Windows.
1 parent 4d16353 commit a066a6e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

stdlib/public/Concurrency/DispatchGlobalExecutor.inc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,18 @@ static void initializeDispatchEnqueueFunc(dispatch_queue_t queue, void *obj,
8484
dispatch_qos_class_t qos) {
8585
dispatchEnqueueFuncType func = nullptr;
8686

87-
// Always fall back to plain dispatch_async_f on Windows for now, and
88-
// also for back-deployed concurrency.
89-
#if !defined(_WIN32) && !defined(SWIFT_CONCURRENCY_BACK_DEPLOYMENT)
87+
// Always fall back to plain dispatch_async_f for back-deployed concurrency.
88+
#if !defined(SWIFT_CONCURRENCY_BACK_DEPLOYMENT)
9089
if (runtime::environment::concurrencyEnableJobDispatchIntegration())
90+
#if defined(_WIN32)
91+
func = reinterpret_cast<dispatchEnqueueFuncType>(
92+
GetProcAddress(LoadLibraryW(L"dispatch.dll"),
93+
"dispatch_async_swift_job"));
94+
#else
9195
func = reinterpret_cast<dispatchEnqueueFuncType>(
9296
dlsym(RTLD_NEXT, "dispatch_async_swift_job"));
97+
98+
#endif
9399
#endif
94100

95101
if (!func)

0 commit comments

Comments
 (0)