5959#include " TaskPrivate.h"
6060#include " Error.h"
6161
62- #if SWIFT_CONCURRENCY_ENABLE_DISPATCH
62+ #if !SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
6363#include < dispatch/dispatch.h>
6464
6565#if !defined(_WIN32)
@@ -178,21 +178,15 @@ static Job *claimNextFromJobQueue() {
178178 }
179179}
180180
181- void swift::
182- swift_task_donateThreadToGlobalExecutorUntil (bool (*condition)(void *),
183- void *conditionContext) {
181+ void swift::donateThreadToGlobalExecutorUntil (bool (*condition)(void *),
182+ void *conditionContext) {
184183 while (!condition (conditionContext)) {
185184 auto job = claimNextFromJobQueue ();
186185 if (!job) return ;
187186 swift_job_run (job, ExecutorRef::generic ());
188187 }
189188}
190189
191- #elif !SWIFT_CONCURRENCY_ENABLE_DISPATCH
192-
193- // No implementation. The expectation is that integrators in this
194- // configuration will hook all the appropriate functions.
195-
196190#else
197191
198192// Ensure that Job's layout is compatible with what Dispatch expects.
@@ -336,9 +330,6 @@ static void swift_task_enqueueGlobalImpl(Job *job) {
336330
337331#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
338332 insertIntoJobQueue (job);
339- #elif !SWIFT_CONCURRENCY_ENABLE_DISPATCH
340- swift_reportError (0 , " operation unsupported without libdispatch: "
341- " swift_task_enqueueGlobal" );
342333#else
343334 // We really want four things from the global execution service:
344335 // - Enqueuing work should have minimal runtime and memory overhead.
@@ -394,9 +385,6 @@ static void swift_task_enqueueGlobalWithDelayImpl(unsigned long long delay,
394385
395386#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
396387 insertIntoDelayedJobQueue (delay, job);
397- #elif !SWIFT_CONCURRENCY_ENABLE_DISPATCH
398- swift_reportError (0 , " operation unsupported without libdispatch: "
399- " swift_task_enqueueGlobalWithDelay" );
400388#else
401389
402390 dispatch_function_t dispatchFunction = &__swift_run_job;
@@ -431,9 +419,6 @@ static void swift_task_enqueueMainExecutorImpl(Job *job) {
431419
432420#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
433421 insertIntoJobQueue (job);
434- #elif !SWIFT_CONCURRENCY_ENABLE_DISPATCH
435- swift_reportError (0 , " operation unsupported without libdispatch: "
436- " swift_task_enqueueMainExecutor" );
437422#else
438423
439424 JobPriority priority = job->getPriority ();
@@ -454,7 +439,7 @@ void swift::swift_task_enqueueMainExecutor(Job *job) {
454439 swift_task_enqueueMainExecutorImpl (job);
455440}
456441
457- #if SWIFT_CONCURRENCY_ENABLE_DISPATCH
442+ #if !SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
458443void swift::swift_task_enqueueOnDispatchQueue (Job *job,
459444 HeapObject *_queue) {
460445 JobPriority priority = job->getPriority ();
@@ -464,8 +449,7 @@ void swift::swift_task_enqueueOnDispatchQueue(Job *job,
464449#endif
465450
466451ExecutorRef swift::swift_task_getMainExecutor () {
467- #if !SWIFT_CONCURRENCY_ENABLE_DISPATCH
468- // FIXME: this isn't right for the non-cooperative environment
452+ #if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
469453 return ExecutorRef::generic ();
470454#else
471455 return ExecutorRef::forOrdinary (
@@ -475,8 +459,7 @@ ExecutorRef swift::swift_task_getMainExecutor() {
475459}
476460
477461bool ExecutorRef::isMainExecutor () const {
478- #if !SWIFT_CONCURRENCY_ENABLE_DISPATCH
479- // FIXME: this isn't right for the non-cooperative environment
462+ #if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
480463 return isGeneric ();
481464#else
482465 return Identity == reinterpret_cast <HeapObject*>(&_dispatch_main_q);
0 commit comments