|
59 | 59 | #include "TaskPrivate.h" |
60 | 60 | #include "Error.h" |
61 | 61 |
|
| 62 | +#if !SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR |
62 | 63 | #include <dispatch/dispatch.h> |
63 | 64 |
|
64 | 65 | #if !defined(_WIN32) |
65 | 66 | #include <dlfcn.h> |
66 | 67 | #endif |
67 | 68 |
|
| 69 | +#endif |
| 70 | + |
68 | 71 | using namespace swift; |
69 | 72 |
|
70 | 73 | SWIFT_CC(swift) |
@@ -180,7 +183,7 @@ void swift::donateThreadToGlobalExecutorUntil(bool (*condition)(void *), |
180 | 183 | while (!condition(conditionContext)) { |
181 | 184 | auto job = claimNextFromJobQueue(); |
182 | 185 | if (!job) return; |
183 | | - job->run(ExecutorRef::generic()); |
| 186 | + swift_job_run(job, ExecutorRef::generic()); |
184 | 187 | } |
185 | 188 | } |
186 | 189 |
|
@@ -405,21 +408,35 @@ void swift::swift_task_enqueueMainExecutor(Job *job) { |
405 | 408 | swift_task_enqueueMainExecutorImpl(job); |
406 | 409 | } |
407 | 410 |
|
| 411 | +#if !SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR |
408 | 412 | void swift::swift_task_enqueueOnDispatchQueue(Job *job, |
409 | 413 | HeapObject *_queue) { |
410 | 414 | JobPriority priority = job->getPriority(); |
411 | 415 | auto queue = reinterpret_cast<dispatch_queue_t>(_queue); |
412 | 416 | dispatchEnqueue(queue, job, (dispatch_qos_class_t)priority, queue); |
413 | 417 | } |
| 418 | +#endif |
| 419 | + |
| 420 | +#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR |
| 421 | +static HeapObject _swift_mainExecutorIdentity; |
| 422 | +#endif |
414 | 423 |
|
415 | 424 | ExecutorRef swift::swift_task_getMainExecutor() { |
| 425 | +#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR |
| 426 | + return ExecutorRef::forOrdinary(&_swift_mainExecutorIdentity, nullptr); |
| 427 | +#else |
416 | 428 | return ExecutorRef::forOrdinary( |
417 | 429 | reinterpret_cast<HeapObject*>(&_dispatch_main_q), |
418 | 430 | _swift_task_getDispatchQueueSerialExecutorWitnessTable()); |
| 431 | +#endif |
419 | 432 | } |
420 | 433 |
|
421 | 434 | bool ExecutorRef::isMainExecutor() const { |
| 435 | +#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR |
| 436 | + return Identity == &_swift_mainExecutorIdentity; |
| 437 | +#else |
422 | 438 | return Identity == reinterpret_cast<HeapObject*>(&_dispatch_main_q); |
| 439 | +#endif |
423 | 440 | } |
424 | 441 |
|
425 | 442 | #define OVERRIDE_GLOBAL_EXECUTOR COMPATIBILITY_OVERRIDE |
|
0 commit comments