|
2 | 2 | //
|
3 | 3 | // This source file is part of the Swift.org open source project
|
4 | 4 | //
|
5 |
| -// Copyright (c) 2020 Apple Inc. and the Swift project authors |
| 5 | +// Copyright (c) 2020-2022 Apple Inc. and the Swift project authors |
6 | 6 | // Licensed under Apache License v2.0 with Runtime Library Exception
|
7 | 7 | //
|
8 | 8 | // See https://swift.org/LICENSE.txt for license information
|
|
13 | 13 | import Swift
|
14 | 14 | @_implementationOnly import _SwiftConcurrencyShims
|
15 | 15 |
|
| 16 | +/// Common marker protocol providing a shared "base" for both (local) `Actor` |
| 17 | +/// and (potentially remote) `DistributedActor` types. |
| 18 | +/// |
| 19 | +/// The `AnyActor` marker protocol generalizes over all actor types, including |
| 20 | +/// distributed ones. In practice, this protocol can be used to restrict |
| 21 | +/// protocols, or generic parameters to only be usable with actors, which |
| 22 | +/// provides the guarantee that calls may be safely made on instances of given |
| 23 | +/// type without worrying about the thread-safety of it -- as they are |
| 24 | +/// guaranteed to follow the actor-style isolation semantics. |
| 25 | +/// |
| 26 | +/// While both local and distributed actors are conceptually "actors", there are |
| 27 | +/// some important isolation model differences between the two, which make it |
| 28 | +/// impossible for one to refine the other. |
| 29 | +@_marker |
| 30 | +@available(SwiftStdlib 5.1, *) |
| 31 | +public protocol AnyActor: AnyObject, Sendable {} |
| 32 | + |
16 | 33 | /// Common protocol to which all actors conform.
|
17 | 34 | ///
|
18 |
| -/// The `Actor` protocol generalizes over all actor types. Actor types |
| 35 | +/// The `Actor` protocol generalizes over all `actor` types. Actor types |
19 | 36 | /// implicitly conform to this protocol.
|
20 | 37 | @available(SwiftStdlib 5.1, *)
|
21 |
| -public protocol Actor: AnyObject, Sendable { |
| 38 | +public protocol Actor: AnyActor, Sendable { |
22 | 39 |
|
23 | 40 | /// Retrieve the executor for this actor as an optimized, unowned
|
24 | 41 | /// reference.
|
|
0 commit comments