@@ -2016,16 +2016,63 @@ findDistributedAccessor(const char *targetNameStart, size_t targetNameLength) {
2016
2016
return nullptr ;
2017
2017
}
2018
2018
2019
+ // / func _executeDistributedTarget(
2020
+ // / on: AnyObject,
2021
+ // / _ targetName: UnsafePointer<UInt8>,
2022
+ // / _ targetNameLength: UInt,
2023
+ // / argumentBuffer: Builtin.RawPointer,
2024
+ // / resultBuffer: Builtin.RawPointer) async throws
2025
+ using TargetExecutorSignature =
2026
+ AsyncSignature<void (DefaultActor *, const char *, size_t , void *, void *),
2027
+ /* throws=*/ true >;
2028
+
2029
+ SWIFT_CC (swiftasync)
2030
+ SWIFT_RUNTIME_STDLIB_SPI
2031
+ TargetExecutorSignature::FunctionType swift_distributed_execute_target;
2032
+
2033
+ // / Accessor takes a context, an argument buffer as a raw pointer,
2034
+ // / and a reference to an actor.
2035
+ using DistributedAccessorSignature = AsyncSignature<void (void *, HeapObject *),
2036
+ /* throws=*/ true >;
2037
+
2038
+ SWIFT_CC (swiftasync)
2039
+ static DistributedAccessorSignature::ContinuationType
2040
+ swift_distributed_execute_target_resume;
2041
+
2042
+ SWIFT_CC (swiftasync)
2043
+ static void ::swift_distributed_execute_target_resume(
2044
+ SWIFT_ASYNC_CONTEXT AsyncContext *context, SWIFT_CONTEXT void *error) {
2045
+ auto parentCtx = context->Parent ;
2046
+ auto resumeInParent =
2047
+ reinterpret_cast <TargetExecutorSignature::ContinuationType *>(
2048
+ parentCtx->ResumeParent );
2049
+ swift_task_dealloc (context);
2050
+ return resumeInParent (parentCtx, error);
2051
+ }
2052
+
2019
2053
SWIFT_CC (swiftasync)
2020
- void swift_distributed_execute_target(
2021
- OpaqueValue *resultPointer,
2022
- SWIFT_ASYNC_CONTEXT AsyncContext *callerContext,
2023
- DefaultActor *actor,
2024
- const char *targetNameStart, size_t targetNameLength,
2025
- void *argumentBuffer,
2026
- void *resultBuffer,
2027
- ThrowingTaskFutureWaitContinuationFunction *resumeFn,
2028
- AsyncContext *callContext) {
2054
+ void ::swift_distributed_execute_target(
2055
+ SWIFT_ASYNC_CONTEXT AsyncContext *callerContext, DefaultActor *actor,
2056
+ const char *targetNameStart, size_t targetNameLength, void *argumentBuffer,
2057
+ void *resultBuffer) {
2029
2058
auto *accessor = findDistributedAccessor (targetNameStart, targetNameLength);
2030
- (void )accessor;
2059
+
2060
+ if (!accessor)
2061
+ return ;
2062
+
2063
+ auto *asyncFnPtr = reinterpret_cast <
2064
+ const AsyncFunctionPointer<DistributedAccessorSignature> *>(accessor);
2065
+
2066
+ DistributedAccessorSignature::FunctionType *accessorEntry =
2067
+ asyncFnPtr->Function .get ();
2068
+
2069
+ AsyncContext *calleeContext = reinterpret_cast <AsyncContext *>(
2070
+ swift_task_alloc (asyncFnPtr->ExpectedContextSize ));
2071
+
2072
+ calleeContext->Parent = callerContext;
2073
+ calleeContext->ResumeParent = reinterpret_cast <TaskContinuationFunction *>(
2074
+ swift_distributed_execute_target_resume);
2075
+
2076
+ // TODO: Add resultBuffer as an argument to store an indirect result into.
2077
+ accessorEntry (calleeContext, argumentBuffer, actor);
2031
2078
}
0 commit comments