AnyActor
Common marker protocol providing a shared “base” for both (local) Actor
and (potentially remote) DistributedActor
types.
This declaration is deprecated: Use 'any Actor' with 'DistributedActor.asLocalActor' instead
typealias AnyActor = AnyObject & Sendable
The AnyActor
marker protocol generalizes over all actor types, including distributed ones. In practice, this protocol can be used to restrict protocols, or generic parameters to only be usable with actors, which provides the guarantee that calls may be safely made on instances of given type without worrying about the thread-safety of it – as they are guaranteed to follow the actor-style isolation semantics.
While both local and distributed actors are conceptually “actors”, there are some important isolation model differences between the two, which make it impossible for one to refine the other.