Skip to content

Commit d95a31e

Browse files
committed
[Distributed] Drop class requirement from DistributedTargetInvocationDecoder
This allows us to avoid heap allocation and reference counting when working with decoders. Also both (public and internal) distributed target execution methods has been made generic over a decoder type.
1 parent 352b3a2 commit d95a31e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

stdlib/public/Distributed/DistributedActorSystem.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ extension DistributedActorSystem {
154154
public func executeDistributedTarget<Act, ResultHandler>(
155155
on actor: Act,
156156
mangledTargetName: String,
157-
invocationDecoder: InvocationDecoder,
157+
invocationDecoder: inout InvocationDecoder,
158158
handler: ResultHandler
159159
) async throws where Act: DistributedActor,
160160
// Act.ID == ActorID, // FIXME(distributed): can we bring this back?
@@ -289,7 +289,7 @@ extension DistributedActorSystem {
289289
try await _executeDistributedTarget(
290290
on: actor,
291291
mangledTargetName, UInt(mangledTargetName.count),
292-
argumentDecoder: invocationDecoder,
292+
argumentDecoder: &invocationDecoder,
293293
argumentTypes: argumentTypesBuffer.baseAddress!._rawValue,
294294
resultBuffer: resultBuffer._rawValue,
295295
substitutions: UnsafeRawPointer(substitutionsBuffer),
@@ -309,10 +309,10 @@ extension DistributedActorSystem {
309309

310310
@available(SwiftStdlib 5.7, *)
311311
@_silgen_name("swift_distributed_execute_target")
312-
func _executeDistributedTarget(
312+
func _executeDistributedTarget<D: DistributedTargetInvocationDecoder>(
313313
on actor: AnyObject, // DistributedActor
314314
_ targetName: UnsafePointer<UInt8>, _ targetNameLength: UInt,
315-
argumentDecoder: AnyObject, // concrete type for `InvocationDecoder`
315+
argumentDecoder: inout D,
316316
argumentTypes: Builtin.RawPointer,
317317
resultBuffer: Builtin.RawPointer,
318318
substitutions: UnsafeRawPointer?,
@@ -400,10 +400,10 @@ public protocol DistributedTargetInvocationEncoder {
400400

401401
/// Decoder that must be provided to `executeDistributedTarget` and is used
402402
/// by the Swift runtime to decode arguments of the invocation.
403-
public protocol DistributedTargetInvocationDecoder : AnyObject {
403+
public protocol DistributedTargetInvocationDecoder {
404404
associatedtype SerializationRequirement
405405

406-
func decodeGenericSubstitutions() throws -> [Any.Type]
406+
mutating func decodeGenericSubstitutions() throws -> [Any.Type]
407407

408408
// /// Ad-hoc protocol requirement
409409
// ///
@@ -420,9 +420,9 @@ public protocol DistributedTargetInvocationDecoder : AnyObject {
420420
// /// performs the actual distributed (local) instance method invocation.
421421
// mutating func decodeNextArgument<Argument: SerializationRequirement>() throws -> Argument
422422

423-
func decodeErrorType() throws -> Any.Type?
423+
mutating func decodeErrorType() throws -> Any.Type?
424424

425-
func decodeReturnType() throws -> Any.Type?
425+
mutating func decodeReturnType() throws -> Any.Type?
426426
}
427427

428428
@available(SwiftStdlib 5.7, *)

0 commit comments

Comments
 (0)