Skip to content

Commit d54e329

Browse files
committed
[Distributed] Runtime: Implement a way to access generic env of distributed target
1 parent 2bd7a49 commit d54e329

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

stdlib/public/Concurrency/Actor.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1709,6 +1709,14 @@ findDistributedAccessor(const char *targetNameStart, size_t targetNameLength) {
17091709
return nullptr;
17101710
}
17111711

1712+
SWIFT_CC(swift)
1713+
SWIFT_RUNTIME_STDLIB_SPI
1714+
void *swift_distributed_get_generic_environment(const char *targetNameStart,
1715+
size_t targetNameLength) {
1716+
auto *accessor = findDistributedAccessor(targetNameStart, targetNameLength);
1717+
return accessor ? accessor->GenericEnvironment.get() : nullptr;
1718+
}
1719+
17121720
/// func _executeDistributedTarget(
17131721
/// on: AnyObject,
17141722
/// _ targetName: UnsafePointer<UInt8>,
@@ -1766,7 +1774,7 @@ void ::swift_distributed_execute_target(
17661774
AsyncContext *callContext) {
17671775
auto *accessor = findDistributedAccessor(targetNameStart, targetNameLength);
17681776
if (!accessor) {
1769-
assert(false && "no distributed accessor accessor");
1777+
assert(false && "no distributed accessor");
17701778
return; // FIXME(distributed): return -1 here so the lib can fail the call
17711779
}
17721780

stdlib/public/Distributed/DistributedMetadata.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,14 @@ func __getReturnTypeInfo(
7878
_ typeNameStart: UnsafePointer<UInt8>,
7979
_ typeNameLength: UInt
8080
) -> Any.Type?
81+
82+
83+
/// Retrieve a generic environment descriptor associated with
84+
/// the given distributed target
85+
@available(SwiftStdlib 5.6, *)
86+
@_silgen_name("swift_distributed_get_generic_environment")
87+
public // SPI _Distributed
88+
func _getGenericEnvironmentOfDistributedTarget(
89+
_ targetNameStart: UnsafePointer<UInt8>,
90+
_ targetNameLength: UInt
91+
) -> UnsafeRawPointer?

0 commit comments

Comments
 (0)