Skip to content

Commit 8b27d5e

Browse files
kateinoigakukunMaxDesiatov
authored andcommitted
[Concurrency] repair cooperative global executor
This patch guards some includes of libdispatch headers so that platforms that doesn't support libdispatch can build cooperative executor runtime. And fixed missing implementations for cooperative mode. # Conflicts: # stdlib/public/Concurrency/GlobalExecutor.cpp
1 parent 8e48f7e commit 8b27d5e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

stdlib/public/Concurrency/GlobalExecutor.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,13 @@ void swift::swift_task_enqueueOnDispatchQueue(Job *job,
447447
}
448448
#endif
449449

450+
#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
451+
static HeapObject _swift_mainExecutorIdentity;
452+
#endif
453+
450454
ExecutorRef swift::swift_task_getMainExecutor() {
451455
#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
452-
return ExecutorRef::generic();
456+
return ExecutorRef::forOrdinary(&_swift_mainExecutorIdentity, nullptr);
453457
#else
454458
return ExecutorRef::forOrdinary(
455459
reinterpret_cast<HeapObject*>(&_dispatch_main_q),
@@ -459,7 +463,7 @@ ExecutorRef swift::swift_task_getMainExecutor() {
459463

460464
bool ExecutorRef::isMainExecutor() const {
461465
#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
462-
return isGeneric();
466+
return Identity == &_swift_mainExecutorIdentity;
463467
#else
464468
return Identity == reinterpret_cast<HeapObject*>(&_dispatch_main_q);
465469
#endif

0 commit comments

Comments
 (0)