Check the compiler version instead

This commit is contained in:
Guoye Zhang committed 2024-10-28 18:34:49 -07:00
1 parent 06a234b69b
commit 32a95f29c1
1 file changed
+7 -7
+7 -7
View File
@@ -12,9 +12,9 @@
//
//===----------------------------------------------------------------------===//
#if canImport(Synchronization)
#if compiler(>=6.0)
import Synchronization
#endif // canImport(Synchronization)
#endif // compiler(>=6.0)
/// A collection of HTTP fields. It is used in `HTTPRequest` and `HTTPResponse`, and can also be
/// used as HTTP trailer fields.
@@ -109,7 +109,7 @@ public struct HTTPFields: Sendable, Hashable {
}
}
#if canImport(Synchronization)
#if compiler(>=6.0)
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
private final class _StorageWithMutex: _Storage, @unchecked Sendable {
let mutex = Mutex<Void>(())
@@ -120,7 +120,7 @@ public struct HTTPFields: Sendable, Hashable {
}
}
}
#endif // canImport(Synchronization)
#endif // compiler(>=6.0)
private final class _StorageWithNIOLock: _Storage, @unchecked Sendable {
let lock = LockStorage.create(value: ())
@@ -133,15 +133,15 @@ public struct HTTPFields: Sendable, Hashable {
}
private var _storage = {
#if canImport(Synchronization)
#if compiler(>=6.0)
if #available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) {
_StorageWithMutex()
} else {
_StorageWithNIOLock()
}
#else // canImport(Synchronization)
#else // compiler(>=6.0)
_StorageWithNIOLock()
#endif // canImport(Synchronization)
#endif // compiler(>=6.0)
}()
/// Create an empty list of HTTP fields