Skip to content

Commit 5da91ff

Browse files
[Concurrency] repair cooperative main executor
This patch repairs the build failure for cooperative executor. And also fixed main executor to avoid assertion failure due to `witnessTable == nullptr`
1 parent a66435c commit 5da91ff

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

stdlib/public/Concurrency/GlobalExecutor.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static DelayedJob *DelayedJobQueue = nullptr;
103103

104104
/// Get the next-in-queue storage slot.
105105
static Job *&nextInQueue(Job *cur) {
106-
return reinterpret_cast<Job*&>(&cur->SchedulerPrivate[NextWaitingTaskIndex]);
106+
return reinterpret_cast<Job*&>(cur->SchedulerPrivate[Job::NextWaitingTaskIndex]);
107107
}
108108

109109
/// Insert a job into the cooperative global queue.
@@ -448,13 +448,9 @@ void swift::swift_task_enqueueOnDispatchQueue(Job *job,
448448
}
449449
#endif
450450

451-
#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
452-
static HeapObject _swift_mainExecutorIdentity;
453-
#endif
454-
455451
ExecutorRef swift::swift_task_getMainExecutor() {
456452
#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
457-
return ExecutorRef::forOrdinary(&_swift_mainExecutorIdentity, nullptr);
453+
return ExecutorRef::generic();
458454
#else
459455
return ExecutorRef::forOrdinary(
460456
reinterpret_cast<HeapObject*>(&_dispatch_main_q),
@@ -464,7 +460,7 @@ ExecutorRef swift::swift_task_getMainExecutor() {
464460

465461
bool ExecutorRef::isMainExecutor() const {
466462
#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
467-
return Identity == &_swift_mainExecutorIdentity;
463+
return isGeneric();
468464
#else
469465
return Identity == reinterpret_cast<HeapObject*>(&_dispatch_main_q);
470466
#endif

0 commit comments

Comments
 (0)