fix
This commit is contained in:
parent
f6288ee07d
commit
40ecb14faf
@ -34,7 +34,7 @@ actor SDLSuperClientActor {
|
||||
case command(UInt32, SDLCommand)
|
||||
}
|
||||
|
||||
enum SDLSuperClientError: Error {
|
||||
enum SuperClientError: Error {
|
||||
case timeout
|
||||
case connectionClosed
|
||||
case cancelled
|
||||
@ -133,6 +133,9 @@ actor SDLSuperClientActor {
|
||||
self.inboundContinuation.finish()
|
||||
self.writeContinuation.finish()
|
||||
self.logger.log("[SDLSuperClient] withTaskCancellationHandler cancel")
|
||||
Task {
|
||||
await self.failAllContinuations(SuperClientError.cancelled)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,11 +173,20 @@ actor SDLSuperClientActor {
|
||||
cont.resume(returning: message)
|
||||
}
|
||||
|
||||
private func failAllContinuations(_ error: Error) {
|
||||
let all = continuations
|
||||
continuations.removeAll()
|
||||
|
||||
for (_, cont) in all {
|
||||
cont.resume(throwing: error)
|
||||
}
|
||||
}
|
||||
|
||||
private func timeout(packetId: UInt32) {
|
||||
guard let cont = self.continuations.removeValue(forKey: packetId) else {
|
||||
return
|
||||
}
|
||||
cont.resume(throwing: SDLSuperClientError.timeout)
|
||||
cont.resume(throwing: SuperClientError.timeout)
|
||||
}
|
||||
|
||||
deinit {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user