Skip to content

Commit 5af5501

Browse files
committed
[Distributed] Runtime: Prototype executeDistributedTarget function
1 parent d65906b commit 5af5501

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

stdlib/public/Concurrency/Actor.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include "../CompatibilityOverride/CompatibilityOverride.h"
2929
#include "swift/Runtime/Atomic.h"
30+
#include "swift/Runtime/AccessibleFunction.h"
3031
#include "swift/Runtime/Casting.h"
3132
#include "swift/Runtime/Once.h"
3233
#include "swift/Runtime/Mutex.h"
@@ -2004,3 +2005,27 @@ bool DefaultActorImpl::isDistributedRemote() {
20042005
auto state = CurrentState.load(std::memory_order_relaxed);
20052006
return state.Flags.isDistributedRemote();
20062007
}
2008+
2009+
static const AccessibleFunctionRecord *
2010+
findDistributedAccessor(const char *targetNameStart, size_t targetNameLength) {
2011+
if (auto *func = runtime::swift_findAccessibleFunction(targetNameStart,
2012+
targetNameLength)) {
2013+
assert(func->Flags.isDistributed());
2014+
return func;
2015+
}
2016+
return nullptr;
2017+
}
2018+
2019+
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) {
2029+
auto *accessor = findDistributedAccessor(targetNameStart, targetNameLength);
2030+
(void)accessor;
2031+
}

stdlib/public/Distributed/DistributedActor.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,13 @@ func __isLocalActor(_ actor: AnyObject) -> Bool {
184184

185185
@_silgen_name("swift_distributedActor_remote_initialize")
186186
func _distributedActorRemoteInitialize(_ actorType: Builtin.RawPointer) -> Any
187+
188+
// ==== Remote target accesss -------------------------------------------------
189+
190+
@_silgen_name("swift_distributed_execute_target")
191+
func _executeDistributedTarget(
192+
on: AnyObject,
193+
_ targetName: UnsafePointer<UInt8>,
194+
_ targetNameLength: UInt,
195+
argumentBuffer: Builtin.RawPointer,
196+
resultBuffer: Builtin.RawPointer) async throws

0 commit comments

Comments
 (0)