[Pitch] Global actors

Did you consider including a refining protocol?

protocol GlobalActor: Actor {
    var shared: Self { get }
}

I have a library that encodes concurrency context in the type system and limits some functionality to objects (each managing a piece of state) that share the same context. Expressing this in the actor system using the above protocol would look like:

@MyActor
class MyClass<MyActor: GlobalActor> { ... }

As you can see, this would require the protocol as well as the ability to "see" the generic context of a type in attribute declarations. As we expand the use of user-defined attributes I can imagine the latter capability being useful for other things as well.

2 Likes