Protocol_Concurrency5.9.0
GlobalActor
A type that represents a globally-unique actor that can be used to isolate various declarations anywhere in the program.
- iOS
- 13.0+
- macOS
- 10.15+
- tvOS
- 13.0+
- watchOS
- 6.0+
protocol GlobalActor
A type that conforms to the GlobalActor
protocol and is marked with the @globalActor
attribute can be used as a custom attribute. Such types are called global actor types, and can be applied to any declaration to specify that such types are isolated to that global actor type. When using such a declaration from another actor (or from nonisolated code), synchronization is performed through the shared actor instance to ensure mutually-exclusive access to the declaration.
Requirements
associatedtype ActorType : Actor
The type of the shared actor instance that will be used to provide mutually-exclusive access to declarations annotated with the given global actor type.
static var shared: Self.ActorType
The shared actor instance that will be used to provide mutually-exclusive access to declarations annotated with the given global actor type.
static var sharedUnownedExecutor: UnownedSerialExecutor
The shared executor instance that will be used to provide mutually-exclusive access for the global actor.
Citizens in _Concurrency
Members
static func assertIsolated(() -> String, file: StaticString, line: UInt
) Performs an executor check in debug builds.
static func preconditionIsolated(() -> String, file: StaticString, line: UInt
) Unconditionally if the current task is executing on the serial executor of the passed in
actor
, and if not crash the program offering information about the executor mismatch.