Skip to content

Commit 3cf257f

Browse files
authored
Merge pull request #35585 from compnerd/runless
Concurrency: avoid `CFRunLoopRun` on non-Darwin
2 parents f13167d + 472e842 commit 3cf257f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

stdlib/public/Concurrency/Task.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,11 +560,17 @@ void swift::swift_task_asyncMainDrainQueue() {
560560

561561
pfndispatch_main();
562562
#else
563+
// CFRunLoop is not available on non-Darwin targets. Foundation has an
564+
// implementation, but CoreFoundation is not meant to be exposed. We can only
565+
// assume the existence of `CFRunLoopRun` on Darwin platforms, where the
566+
// system provides an implementation of CoreFoundation.
567+
#if defined(__APPLE__)
563568
auto runLoop =
564569
reinterpret_cast<void (*)(void)>(dlsym(RTLD_DEFAULT, "CFRunLoopRun"));
565570
if (runLoop)
566-
runLoop();
567-
else
571+
return runLoop();
572+
#endif
573+
568574
dispatch_main();
569575
#endif
570576
#endif

0 commit comments

Comments
 (0)