Skip to content

Commit 62f9050

Browse files
authored
Merge pull request #35584 from compnerd/single-threaded-drain
Concurrency: support draining the main queue in single threaded mode
2 parents 45e210b + 4f740a4 commit 62f9050

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

stdlib/public/Concurrency/Task.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,12 @@ void swift::swift_continuation_logFailedCheck(const char *message) {
536536
}
537537

538538
void swift::swift_task_asyncMainDrainQueue() {
539+
#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
540+
bool Finished = false;
541+
donateThreadToGlobalExecutorUntil([](void *context) {
542+
return *reinterpret_cast<bool*>(context);
543+
}, &Finished);
544+
#else
539545
#if defined(_WIN32)
540546
static void(FAR *pfndispatch_main)(void) = NULL;
541547

@@ -561,4 +567,5 @@ void swift::swift_task_asyncMainDrainQueue() {
561567
else
562568
dispatch_main();
563569
#endif
570+
#endif
564571
}

0 commit comments

Comments
 (0)