Skip to content

Commit 16b6fcf

Browse files
kateinoigakukunMaxDesiatov
authored andcommitted
[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` # Conflicts: # stdlib/public/Concurrency/GlobalExecutor.cpp
1 parent 8b27d5e commit 16b6fcf

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
@@ -102,7 +102,7 @@ static DelayedJob *DelayedJobQueue = nullptr;
102102

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

108108
/// Insert a job into the cooperative global queue.
@@ -447,13 +447,9 @@ 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-
454450
ExecutorRef swift::swift_task_getMainExecutor() {
455451
#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
456-
return ExecutorRef::forOrdinary(&_swift_mainExecutorIdentity, nullptr);
452+
return ExecutorRef::generic();
457453
#else
458454
return ExecutorRef::forOrdinary(
459455
reinterpret_cast<HeapObject*>(&_dispatch_main_q),
@@ -463,7 +459,7 @@ ExecutorRef swift::swift_task_getMainExecutor() {
463459

464460
bool ExecutorRef::isMainExecutor() const {
465461
#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
466-
return Identity == &_swift_mainExecutorIdentity;
462+
return isGeneric();
467463
#else
468464
return Identity == reinterpret_cast<HeapObject*>(&_dispatch_main_q);
469465
#endif

0 commit comments

Comments
 (0)