Files
2022-02-08 11:48:58 +01:00

35 lines
1.1 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the AsyncHTTPClient open source project
//
// Copyright (c) 2022 Apple Inc. and the AsyncHTTPClient project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of AsyncHTTPClient project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#if compiler(>=5.5.2) && canImport(_Concurrency)
extension HTTPClient {
/// Shuts down the client and `EventLoopGroup` if it was created by the client.
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public func shutdown() async throws {
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
self.shutdown { error in
switch error {
case .none:
continuation.resume()
case .some(let error):
continuation.resume(throwing: error)
}
}
}
}
}
#endif