SE-0392: Custom Actor Executors

Something I think the proposal should clarify is how custom executors for a distributed actor will work. In particular, for this new protocol requirement:

public protocol DistributedActor: AnyActor {
  /// ...
  nonisolated var unownedExecutor: UnownedSerialExecutor { get }
}

what happens when the instance is remote? There isn't really an executor for the "proxy" instances. Since it's nonisolated, we can't make a call to the remote instance to ask about the executor. And even if we could, these executors aren't really Codable.

One idea is to make the type of unownedExecutor for a distributed actor return an optional. You'd get back nil only in the remote case. A downside is that I forsee this optionality being abused as a non-async form of whenLocal to query whether the instance is local.

2 Likes