Skip to content

[Concurrency] Reference dispatch_async_swift_job directly when the header is available. #73945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion stdlib/public/Concurrency/DispatchGlobalExecutor.inc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
#endif
#endif

#if __has_include(<dispatch/private.h>)
#include <dispatch/private.h>
#define SWIFT_CONCURRENCY_HAS_DISPATCH_PRIVATE 1
#endif

// Ensure that Job's layout is compatible with what Dispatch expects.
// Note: MinimalDispatchObjectHeader just has the fields we care about, it is
// not complete and should not be used for anything other than these asserts.
Expand Down Expand Up @@ -89,7 +94,10 @@ static void initializeDispatchEnqueueFunc(dispatch_queue_t queue, void *obj,
// Always fall back to plain dispatch_async_f for back-deployed concurrency.
#if !defined(SWIFT_CONCURRENCY_BACK_DEPLOYMENT)
if (runtime::environment::concurrencyEnableJobDispatchIntegration())
#if defined(_WIN32)
#if SWIFT_CONCURRENCY_HAS_DISPATCH_PRIVATE
if (SWIFT_RUNTIME_WEAK_CHECK(dispatch_async_swift_job))
func = SWIFT_RUNTIME_WEAK_USE(dispatch_async_swift_job);
#elif defined(_WIN32)
func = reinterpret_cast<dispatchEnqueueFuncType>(
GetProcAddress(LoadLibraryW(L"dispatch.dll"),
"dispatch_async_swift_job"));
Expand Down