[Executors] Clean up how we unwrap the local executor of distributed custom actor (#64719)

This commit is contained in:
Konrad `ktoso` Malawski
2023-03-30 06:22:48 +09:00
committed by GitHub
parent 11b6249dc9
commit edb66df377
3 changed files with 32 additions and 41 deletions

View File

@@ -278,19 +278,15 @@ public protocol DistributedActor: AnyActor, Identifiable, Hashable
/// - Parameter system: `system` which should be used to resolve the `identity`, and be associated with the returned actor
static func resolve(id: ID, using system: ActorSystem) throws -> Self
// FIXME: figure out how to remove this so LowerHopToActor can call the extension method directly on the protocol
@available(SwiftStdlib 5.9, *)
var _unwrapLocalUnownedExecutor: UnownedSerialExecutor { get }
}
@available(SwiftStdlib 5.9, *)
extension DistributedActor {
@available(SwiftStdlib 5.9, *)
public var _unwrapLocalUnownedExecutor: UnownedSerialExecutor {
self.localUnownedExecutor!
public func _getUnwrapLocalDistributedActorUnownedExecutor(_ actor: some DistributedActor) -> UnownedSerialExecutor {
guard let executor = actor.localUnownedExecutor else {
fatalError("Expected distributed actor executor to be not nil!")
}
return executor
}
// ==== Hashable conformance ---------------------------------------------------