Generic over global actor?

Is it possible to make a type generic over a global actor? Essentially, I'm trying to create something that looks like this...

@Isolation
final class Store<State, Action, Isolation: GlobalActor> {
  //...
}

typealias MainStore = Store<State, Action, MainActor>

This way, I could create a Store that is guaranteed to run on the main actor, but I could also, say, make a Store that's guaranteed to be isolated to a global database actor.

Is this or something similar possible?

3 Likes

You can write a macro which emits a type confined to a specific global actor, but this isn't possible with generics.