Instance Propertyswift 6.0.1Distributed
asLocalActor
Produces an erased any Actor
reference to this known to be local distributed actor.
- iOS
- 16.0+
- macOS
- 13.0+
- tvOS
- 16.0+
- watchOS
- 9.0+
@backDeployed(before: macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0)
var asLocalActor: any Actor { get }
Since this method is not distributed, it can only be invoked when the underlying distributed actor is known to be local, e.g. from a context that is isolated to this actor.
Such reference can be used to work with APIs accepting isolated any Actor
, as only a local distributed actor can be isolated on and may be automatically erased to such any Actor
when calling methods implicitly accepting the caller’s actor isolation, e.g. by using the #isolation
macro.
Other members in extension
Type members
nonisolated static func == (lhs: Self, rhs: Self
) -> Bool A distributed actor’s hash and equality is implemented by directly delegating to its
id
.
Instance members
nonisolated func assertIsolated(@autoclosure () -> String, file: StaticString, line: UInt
) Stops program execution if the current task is not executing on this actor’s serial executor.
nonisolated func assumeIsolated<T>((isolated Self) throws -> T, file: StaticString, line: UInt
) rethrows -> T Assume that the current task is executing on this (local) distributed actor’s serial executor, or stop program execution otherwise.
nonisolated func hash(into: inout Hasher
) A distributed actor’s hash and equality is implemented by directly delegating to its
id
.nonisolated func preconditionIsolated(@autoclosure () -> String, file: StaticString, line: UInt
) Stops program execution if the current task is not executing on this actor’s serial executor.
nonisolated func whenLocal<T, E>((isolated Self)
async throws Executes the passed ‘body’ only when the distributed actor is local instance.