[Distributed] fix all distributed runtime tests; they are currently not running on CI (#38502)

This commit is contained in:
Konrad `ktoso` Malawski
2021-07-21 11:36:27 +09:00
committed by GitHub
parent 5c22dd51c1
commit 620a541b0f
8 changed files with 204 additions and 131 deletions

View File

@@ -126,13 +126,16 @@ extension DistributedActor {
public protocol ActorIdentity: Sendable, Hashable, Codable {}
@available(SwiftStdlib 5.5, *)
public struct AnyActorIdentity: ActorIdentity, @unchecked Sendable {
public struct AnyActorIdentity: ActorIdentity, @unchecked Sendable, CustomStringConvertible {
@usableFromInline let _hashInto: (inout Hasher) -> ()
@usableFromInline let _equalTo: (Any) -> Bool
@usableFromInline let _encodeTo: (Encoder) throws -> ()
@usableFromInline let _description: () -> String
public init<ID>(_ identity: ID) where ID: ActorIdentity {
_hashInto = { hasher in identity.hash(into: &hasher) }
_hashInto = { hasher in identity
.hash(into: &hasher)
}
_equalTo = { other in
guard let rhs = other as? ID else {
return false
@@ -142,6 +145,9 @@ public struct AnyActorIdentity: ActorIdentity, @unchecked Sendable {
_encodeTo = { encoder in
try identity.encode(to: encoder)
}
_description = { () in
"\(identity)"
}
}
public init(from decoder: Decoder) throws {
@@ -158,6 +164,10 @@ public struct AnyActorIdentity: ActorIdentity, @unchecked Sendable {
try _encodeTo(encoder)
}
public var description: String {
"\(Self.self)(\(self._description()))"
}
public func hash(into hasher: inout Hasher) {
_hashInto(&hasher)
}