[Concurrency] Actors & actor isolation

If we wanted to extend my design to support a unique queue per-instance like the default actor class I think we could do that like this:


/// Only `Never` conforms
protocol _ActorContext {}

/// User-defined global actor context types conform to this protocol:
protocol GlobalActorContext: _ActorContext {}

// If necessary, this protocol could get special treatment allowing for existentials
// until generalized existentials are a feature
protocol Actor {
    // If users ever specify an explicit ActorContext without conforming to `GlobalActor` 
    // they get a warning or error
    associatedtype ActorContext: _ActorContext = Never
}
protocol GlobalActor: Actor {
    associatedtype ActorContext: GlobalActorContext
}

With this design in hand, my Store class would use a conditional conformance:

final actor class Store<Value, Action, Context> { ... }
extension Store: GlobalActor where Context: GlobalActorContext {}

API that needs to rely on actors sharing a serialization context would be written to constrain the context of both actors to be identical and to conform to the GlobalActorContext protocol (and therefore only available on some instances). Any API whose implementation does not rely on that constraint would be available on all instances, even those with a unique serialization context.

It is a class that serializes access to state. I don't think the details very relevant to this discussion.