Required Instance Methodswift 6.0.1Distributed
assignID(_:)
Assign an ActorID
for the passed actor type.
- iOS
- 16.0+
- macOS
- 13.0+
- tvOS
- 16.0+
- watchOS
- 9.0+
func assignID<Act>(_ actorType: Act.Type) -> Self.ActorID where Act : DistributedActor, Self.ActorID == Act.ID
This function is invoked by a distributed actor during its initialization, and the returned address value is stored along with it for the time of its lifetime.
The address MUST uniquely identify the actor, and allow resolving it. E.g. if an actor is created under address addr1
then immediately invoking system.resolve(id: addr1, as: Greeter.self)
MUST return a reference to the same actor.
Other requirements
Type members
associatedtype ActorID
The type ID that will be assigned to any distributed actor managed by this actor system.
associatedtype InvocationDecoder
Type of
DistributedTargetInvocationDecoder
that should be used when decoding invocations duringexecuteDistributedTarget(on:target:invocationDecoder:handler:)
calls.associatedtype InvocationEncoder
Type of
DistributedTargetInvocationEncoder
that should be used when the Swift runtime needs to encode a distributed target call into an encoder, before passing it off toremoteCall(...)
.associatedtype ResultHandler
The type of the result handler which will be offered the results returned by a distributed function invocation called via
executeDistributedTarget(on:target:invocationDecoder:handler:)
.associatedtype SerializationRequirement
The serialization requirement that will be applied to all distributed targets used with this system.
Instance members
func actorReady<Act>(Act
) Invoked during a distributed actor’s initialization, as soon as it becomes fully initialized.
func invokeHandlerOnReturn(handler: Self.ResultHandler, resultBuffer: UnsafeRawPointer, metatype: any Any.Type
) async throws Implementation synthesized by the compiler. Not intended to be invoked explicitly from user code!
func makeInvocationEncoder(
) -> Self.InvocationEncoder Invoked by the Swift runtime when a distributed remote call is about to be made.
func remoteCall<Act, Err, Res>(on: Act, target: RemoteCallTarget, invocation: inout Self.InvocationEncoder, throwing: Err.Type, returning: Res.Type
) async throws -> Res Invoked by the Swift runtime when making a remote call.
func remoteCallVoid<Act, Err>(on: Act, target: RemoteCallTarget, invocation: inout Self.InvocationEncoder, throwing: Err.Type
) async throws Invoked by the Swift runtime when making a remote call.
func resignID(Self.ActorID
) Called during when a distributed actor is deinitialized, or fails to initialize completely (e.g. by throwing out of an
init
that did not completely initialize all of the actors stored properties yet).func resolve<Act>(id: Self.ActorID, as: Act.Type
) throws -> Act? Resolves a local or remote
ActorID
to a reference to given actor, or throws if unable to.