[Concurrency] Rename ExecutorHooks.h, tidy up the interface.

`ExecutorHooks.h` is now nothing to do with hooks, so rename it.  Also
there are some additional functions it should declare, and a couple of
places where we've slightly messed up the boundary, for instance
`swift_task_asyncMainDrainQueue` was defined in `Task.cpp` rather than
in the executor implementations, which is wrong, so fix that too.

`CooperativeGlobalExecutor.cpp` now builds against the interface from
`ExecutorImpl.h`, rather than including the all the concurrency headers.

rdar://135380149
This commit is contained in:
Alastair Houghton
2024-09-16 14:26:49 +01:00
parent efe5d660f2
commit 26b5fa697a
10 changed files with 679 additions and 289 deletions

View File

@@ -18,20 +18,24 @@
/// This file is included into GlobalExecutor.cpp only when both
/// Dispatch integration and the cooperative global executor are disabled.
/// It is expected to define the following functions:
/// swift_task_asyncMainDrainQueueImpl
/// swift_task_checkIsolatedImpl
/// swift_task_donateThreadToGlobalExecutorUntilImpl
/// swift_task_enqueueGlobalImpl
/// swift_task_enqueueGlobalWithDeadlineImpl
/// swift_task_enqueueGlobalWithDelayImpl
/// swift_task_enqueueMainExecutorImpl
/// swift_task_getMainExecutorImpl
/// swift_task_isMainExecutorImpl
///
///===------------------------------------------------------------------===///
#include "swift/Runtime/Concurrency.h"
#include "swift/Runtime/Debug.h"
#include "ExecutorHooks.h"
using namespace swift;
#include "ExecutorImpl.h"
SWIFT_CC(swift)
void swift::swift_task_enqueueGlobalImpl(Job *job) {
void swift_task_enqueueGlobalImpl(SwiftJob *job) {
assert(job && "no job provided");
swift_reportError(0, "operation unsupported without libdispatch: "
@@ -39,8 +43,8 @@ void swift::swift_task_enqueueGlobalImpl(Job *job) {
}
SWIFT_CC(swift)
void swift::swift_task_enqueueGlobalWithDelayImpl(JobDelay delay,
Job *job) {
void swift_task_enqueueGlobalWithDelayImpl(SwiftJobDelay delay,
SwiftJob *job) {
assert(job && "no job provided");
swift_reportError(0, "operation unsupported without libdispatch: "
@@ -48,11 +52,11 @@ void swift::swift_task_enqueueGlobalWithDelayImpl(JobDelay delay,
}
SWIFT_CC(swift)
void swift::swift_task_enqueueGlobalWithDeadlineImpl(long long sec,
long long nsec,
long long tsec,
long long tnsec,
int clock, Job *job) {
void swift_task_enqueueGlobalWithDeadlineImpl(long long sec,
long long nsec,
long long tsec,
long long tnsec,
int clock, SwiftJob *job) {
assert(job && "no job provided");
swift_reportError(0, "operation unsupported without libdispatch: "
@@ -61,7 +65,7 @@ void swift::swift_task_enqueueGlobalWithDeadlineImpl(long long sec,
/// Enqueues a task on the main executor.
SWIFT_CC(swift)
void swift::swift_task_enqueueMainExecutorImpl(Job *job) {
void swift_task_enqueueMainExecutorImpl(SwiftJob *job) {
assert(job && "no job provided");
swift_reportError(0, "operation unsupported without libdispatch: "
@@ -69,16 +73,29 @@ void swift::swift_task_enqueueMainExecutorImpl(Job *job) {
}
SWIFT_CC(swift)
void swift::swift_task_checkIsolatedImpl(SerialExecutorRef executor) {
swift_task_invokeSwiftCheckIsolated(executor);
void swift_task_checkIsolatedImpl(SwiftExecutorRef executor) {
swift_executor_invokeSwiftCheckIsolated(executor);
}
SWIFT_CC(swift)
SerialExecutorRef swift::swift_task_getMainExecutorImpl() {
return SerialExecutorRef::generic();
SwiftExecutorRef swift_task_getMainExecutorImpl() {
return swift_executor_generic();
}
SWIFT_CC(swift)
bool swift::swift_task_isMainExecutorImpl(SerialExecutorRef executor) {
return executor.isGeneric();
bool swift_task_isMainExecutorImpl(SwiftExecutorRef executor) {
return swift_executor_isGeneric(executor);
}
SWIFT_RUNTIME_ATTRIBUTE_NORETURN SWIFT_CC(swift)
void swift_task_asyncMainDrainQueueImpll() {
swift_reportError(0, "operation unsupported without libdispatch: "
"swift_task_asyncMainDrainQueue");
}
SWIFT_CC(swift) void
swift_task_donateThreadToGlobalExecutorUntilImpl(bool (*condition)(void *),
void *conditionContext) {
swift_reportError(0, "operation unsupported: "
"swift_task_donateThreadToGlobalExecutorUntilImpl");
}