mirror of
https://github.com/apple/swift-nio
synced 2026-11-28 05:14:23 +00:00
Drop Swift 5.10 (#3393)
This PR drops Swift 5.10 and enables Swift 6 language mode. --------- Co-authored-by: Cory Benfield <lukasa@apple.com>
This commit is contained in:
1 parent
2143eb91f1
commit
a3ed8e10ab
37 files changed
+123
-268
No files matched your search
+52
-68
@@ -1,4 +1,4 @@
|
||||
// swift-tools-version:5.10
|
||||
// swift-tools-version:6.0
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the SwiftNIO open source project
|
||||
@@ -23,23 +23,7 @@ let swiftSystem: PackageDescription.Target.Dependency = .product(name: "SystemPa
|
||||
// compatibility with previous NIO versions.
|
||||
let historicalNIOPosixDependencyRequired: [Platform] = [.macOS, .iOS, .tvOS, .watchOS, .linux, .android]
|
||||
|
||||
let strictConcurrencyDevelopment = false
|
||||
|
||||
let strictConcurrencySettings: [SwiftSetting] = {
|
||||
var initialSettings: [SwiftSetting] = []
|
||||
initialSettings.append(contentsOf: [
|
||||
.enableUpcomingFeature("StrictConcurrency"),
|
||||
.enableUpcomingFeature("InferSendableFromCaptures"),
|
||||
])
|
||||
|
||||
if strictConcurrencyDevelopment {
|
||||
// -warnings-as-errors here is a workaround so that IDE-based development can
|
||||
// get tripped up on -require-explicit-sendable.
|
||||
initialSettings.append(.unsafeFlags(["-require-explicit-sendable", "-warnings-as-errors"]))
|
||||
}
|
||||
|
||||
return initialSettings
|
||||
}()
|
||||
let swiftSettings: [SwiftSetting] = []
|
||||
|
||||
// This doesn't work when cross-compiling: the privacy manifest will be included in the Bundle and
|
||||
// Foundation will be linked. This is, however, strictly better than unconditionally adding the
|
||||
@@ -83,15 +67,15 @@ let package = Package(
|
||||
swiftCollections,
|
||||
swiftAtomics,
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.target(
|
||||
name: "_NIODataStructures",
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.target(
|
||||
name: "_NIOBase64",
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.target(
|
||||
name: "NIOEmbedded",
|
||||
@@ -102,7 +86,7 @@ let package = Package(
|
||||
swiftAtomics,
|
||||
swiftCollections,
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.target(
|
||||
name: "NIOPosix",
|
||||
@@ -118,7 +102,7 @@ let package = Package(
|
||||
],
|
||||
exclude: includePrivacyManifest ? [] : ["PrivacyInfo.xcprivacy"],
|
||||
resources: includePrivacyManifest ? [.copy("PrivacyInfo.xcprivacy")] : [],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.target(
|
||||
name: "NIO",
|
||||
@@ -127,7 +111,7 @@ let package = Package(
|
||||
"NIOEmbedded",
|
||||
"NIOPosix",
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.target(
|
||||
name: "_NIOConcurrency",
|
||||
@@ -135,7 +119,7 @@ let package = Package(
|
||||
.target(name: "NIO", condition: .when(platforms: historicalNIOPosixDependencyRequired)),
|
||||
"NIOCore",
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.target(
|
||||
name: "NIOFoundationCompat",
|
||||
@@ -143,7 +127,7 @@ let package = Package(
|
||||
.target(name: "NIO", condition: .when(platforms: historicalNIOPosixDependencyRequired)),
|
||||
"NIOCore",
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.target(
|
||||
name: "CNIOAtomics",
|
||||
@@ -190,7 +174,7 @@ let package = Package(
|
||||
dependencies: [
|
||||
"CNIOAtomics"
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.target(
|
||||
name: "NIOHTTP1",
|
||||
@@ -201,7 +185,7 @@ let package = Package(
|
||||
"CNIOLLHTTP",
|
||||
swiftCollections,
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.target(
|
||||
name: "NIOWebSocket",
|
||||
@@ -212,7 +196,7 @@ let package = Package(
|
||||
"CNIOSHA1",
|
||||
"_NIOBase64",
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.target(
|
||||
name: "CNIOLLHTTP",
|
||||
@@ -228,7 +212,7 @@ let package = Package(
|
||||
"NIOCore",
|
||||
swiftCollections,
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.target(
|
||||
name: "NIOTestUtils",
|
||||
@@ -239,7 +223,7 @@ let package = Package(
|
||||
"NIOHTTP1",
|
||||
swiftAtomics,
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.target(
|
||||
name: "NIOFS",
|
||||
@@ -255,7 +239,7 @@ let package = Package(
|
||||
path: "Sources/NIOFS",
|
||||
exclude: includePrivacyManifest ? [] : ["PrivacyInfo.xcprivacy"],
|
||||
resources: includePrivacyManifest ? [.copy("PrivacyInfo.xcprivacy")] : [],
|
||||
swiftSettings: strictConcurrencySettings + [
|
||||
swiftSettings: swiftSettings + [
|
||||
.define("ENABLE_MOCKING", .when(configuration: .debug))
|
||||
]
|
||||
),
|
||||
@@ -266,7 +250,7 @@ let package = Package(
|
||||
"NIOFoundationCompat",
|
||||
],
|
||||
path: "Sources/NIOFSFoundationCompat",
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
|
||||
.target(
|
||||
@@ -283,7 +267,7 @@ let package = Package(
|
||||
path: "Sources/_NIOFileSystem",
|
||||
exclude: includePrivacyManifest ? [] : ["PrivacyInfo.xcprivacy"],
|
||||
resources: includePrivacyManifest ? [.copy("PrivacyInfo.xcprivacy")] : [],
|
||||
swiftSettings: strictConcurrencySettings + [
|
||||
swiftSettings: swiftSettings + [
|
||||
.define("ENABLE_MOCKING", .when(configuration: .debug))
|
||||
]
|
||||
),
|
||||
@@ -294,12 +278,12 @@ let package = Package(
|
||||
"NIOFoundationCompat",
|
||||
],
|
||||
path: "Sources/_NIOFileSystemFoundationCompat",
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.target(
|
||||
name: "NIOFileSystem",
|
||||
dependencies: ["_NIOFileSystem"],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
|
||||
// MARK: - Examples
|
||||
@@ -311,7 +295,7 @@ let package = Package(
|
||||
"NIOCore",
|
||||
],
|
||||
exclude: ["README.md"],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.executableTarget(
|
||||
name: "NIOTCPEchoClient",
|
||||
@@ -320,7 +304,7 @@ let package = Package(
|
||||
"NIOCore",
|
||||
],
|
||||
exclude: ["README.md"],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.executableTarget(
|
||||
name: "NIOEchoServer",
|
||||
@@ -330,7 +314,7 @@ let package = Package(
|
||||
"NIOConcurrencyHelpers",
|
||||
],
|
||||
exclude: ["README.md"],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.executableTarget(
|
||||
name: "NIOEchoClient",
|
||||
@@ -340,7 +324,7 @@ let package = Package(
|
||||
"NIOConcurrencyHelpers",
|
||||
],
|
||||
exclude: ["README.md"],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.executableTarget(
|
||||
name: "NIOHTTP1Server",
|
||||
@@ -351,7 +335,7 @@ let package = Package(
|
||||
"NIOConcurrencyHelpers",
|
||||
],
|
||||
exclude: ["README.md"],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.executableTarget(
|
||||
name: "NIOHTTP1Client",
|
||||
@@ -362,7 +346,7 @@ let package = Package(
|
||||
"NIOConcurrencyHelpers",
|
||||
],
|
||||
exclude: ["README.md"],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.executableTarget(
|
||||
name: "NIOChatServer",
|
||||
@@ -372,7 +356,7 @@ let package = Package(
|
||||
"NIOConcurrencyHelpers",
|
||||
],
|
||||
exclude: ["README.md"],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.executableTarget(
|
||||
name: "NIOChatClient",
|
||||
@@ -382,7 +366,7 @@ let package = Package(
|
||||
"NIOConcurrencyHelpers",
|
||||
],
|
||||
exclude: ["README.md"],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.executableTarget(
|
||||
name: "NIOWebSocketServer",
|
||||
@@ -393,7 +377,7 @@ let package = Package(
|
||||
"NIOWebSocket",
|
||||
],
|
||||
exclude: ["README.md"],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.executableTarget(
|
||||
name: "NIOWebSocketClient",
|
||||
@@ -404,7 +388,7 @@ let package = Package(
|
||||
"NIOWebSocket",
|
||||
],
|
||||
exclude: ["README.md"],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.executableTarget(
|
||||
name: "NIOMulticastChat",
|
||||
@@ -412,7 +396,7 @@ let package = Package(
|
||||
"NIOPosix",
|
||||
"NIOCore",
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.executableTarget(
|
||||
name: "NIOUDPEchoServer",
|
||||
@@ -421,7 +405,7 @@ let package = Package(
|
||||
"NIOCore",
|
||||
],
|
||||
exclude: ["README.md"],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.executableTarget(
|
||||
name: "NIOUDPEchoClient",
|
||||
@@ -430,7 +414,7 @@ let package = Package(
|
||||
"NIOCore",
|
||||
],
|
||||
exclude: ["README.md"],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.executableTarget(
|
||||
name: "NIOAsyncAwaitDemo",
|
||||
@@ -439,7 +423,7 @@ let package = Package(
|
||||
"NIOCore",
|
||||
"NIOHTTP1",
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
|
||||
// MARK: - Tests
|
||||
@@ -454,7 +438,7 @@ let package = Package(
|
||||
"NIOFoundationCompat",
|
||||
"NIOWebSocket",
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.executableTarget(
|
||||
name: "NIOCrashTester",
|
||||
@@ -466,7 +450,7 @@ let package = Package(
|
||||
"NIOWebSocket",
|
||||
"NIOFoundationCompat",
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.testTarget(
|
||||
name: "NIOCoreTests",
|
||||
@@ -478,7 +462,7 @@ let package = Package(
|
||||
"NIOTestUtils",
|
||||
swiftAtomics,
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.testTarget(
|
||||
name: "NIOEmbeddedTests",
|
||||
@@ -487,7 +471,7 @@ let package = Package(
|
||||
"NIOCore",
|
||||
"NIOEmbedded",
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.testTarget(
|
||||
name: "NIOPosixTests",
|
||||
@@ -502,7 +486,7 @@ let package = Package(
|
||||
"CNIODarwin",
|
||||
"NIOTLS",
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.testTarget(
|
||||
name: "NIOConcurrencyHelpersTests",
|
||||
@@ -510,17 +494,17 @@ let package = Package(
|
||||
"NIOConcurrencyHelpers",
|
||||
"NIOCore",
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.testTarget(
|
||||
name: "NIODataStructuresTests",
|
||||
dependencies: ["_NIODataStructures"],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.testTarget(
|
||||
name: "NIOBase64Tests",
|
||||
dependencies: ["_NIOBase64"],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.testTarget(
|
||||
name: "NIOHTTP1Tests",
|
||||
@@ -532,7 +516,7 @@ let package = Package(
|
||||
"NIOFoundationCompat",
|
||||
"NIOTestUtils",
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.testTarget(
|
||||
name: "NIOTLSTests",
|
||||
@@ -543,7 +527,7 @@ let package = Package(
|
||||
"NIOFoundationCompat",
|
||||
"NIOTestUtils",
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.testTarget(
|
||||
name: "NIOWebSocketTests",
|
||||
@@ -552,7 +536,7 @@ let package = Package(
|
||||
"NIOEmbedded",
|
||||
"NIOWebSocket",
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.testTarget(
|
||||
name: "NIOTestUtilsTests",
|
||||
@@ -562,7 +546,7 @@ let package = Package(
|
||||
"NIOEmbedded",
|
||||
"NIOPosix",
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.testTarget(
|
||||
name: "NIOFoundationCompatTests",
|
||||
@@ -570,17 +554,17 @@ let package = Package(
|
||||
"NIOCore",
|
||||
"NIOFoundationCompat",
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.testTarget(
|
||||
name: "NIOTests",
|
||||
dependencies: ["NIO"],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.testTarget(
|
||||
name: "NIOSingletonsTests",
|
||||
dependencies: ["NIOCore", "NIOPosix"],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.testTarget(
|
||||
name: "NIOFSTests",
|
||||
@@ -591,7 +575,7 @@ let package = Package(
|
||||
swiftCollections,
|
||||
swiftSystem,
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings + [
|
||||
swiftSettings: swiftSettings + [
|
||||
.define("ENABLE_MOCKING", .when(configuration: .debug))
|
||||
]
|
||||
),
|
||||
@@ -609,7 +593,7 @@ let package = Package(
|
||||
// the build.
|
||||
"Test Data"
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.testTarget(
|
||||
name: "NIOFSFoundationCompatTests",
|
||||
@@ -617,7 +601,7 @@ let package = Package(
|
||||
"NIOFS",
|
||||
"NIOFSFoundationCompat",
|
||||
],
|
||||
swiftSettings: strictConcurrencySettings
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
@@ -86,7 +86,8 @@ SwiftNIO | Minimum Swift Version
|
||||
`2.60.0 ..< 2.65.0` | 5.7
|
||||
`2.65.0 ..< 2.76.0` | 5.8
|
||||
`2.76.0 ..< 2.83.0` | 5.9
|
||||
`2.83.0 ...` | 5.10
|
||||
`2.83.0 ..< 2.87.0` | 5.10
|
||||
`2.87.0 ... ` | 6.0
|
||||
|
||||
### SwiftNIO 1
|
||||
SwiftNIO 1 is considered end of life - it is strongly recommended that you move to a newer version. The Core NIO team does not actively work on this version. No new features will be added to this version but PRs which fix bugs or security vulnerabilities will be accepted until the end of May 2022.
|
||||
|
||||
@@ -19,7 +19,6 @@ import CNIOAtomics
|
||||
/// **Do not add conformance to this protocol for arbitrary types**. Only a small range
|
||||
/// of types have appropriate atomic operations supported by the CPU, and those types
|
||||
/// already have conformances implemented.
|
||||
#if compiler(>=6.0)
|
||||
@preconcurrency
|
||||
public protocol NIOAtomicPrimitive {
|
||||
associatedtype AtomicWrapper
|
||||
@@ -35,18 +34,6 @@ public protocol NIOAtomicPrimitive {
|
||||
static var nio_atomic_load: @Sendable (UnsafeMutablePointer<AtomicWrapper>) -> Self { get }
|
||||
static var nio_atomic_store: @Sendable (UnsafeMutablePointer<AtomicWrapper>, Self) -> Void { get }
|
||||
}
|
||||
#else
|
||||
public protocol NIOAtomicPrimitive {
|
||||
associatedtype AtomicWrapper
|
||||
static var nio_atomic_create_with_existing_storage: (UnsafeMutablePointer<AtomicWrapper>, Self) -> Void { get }
|
||||
static var nio_atomic_compare_and_exchange: (UnsafeMutablePointer<AtomicWrapper>, Self, Self) -> Bool { get }
|
||||
static var nio_atomic_add: (UnsafeMutablePointer<AtomicWrapper>, Self) -> Self { get }
|
||||
static var nio_atomic_sub: (UnsafeMutablePointer<AtomicWrapper>, Self) -> Self { get }
|
||||
static var nio_atomic_exchange: (UnsafeMutablePointer<AtomicWrapper>, Self) -> Self { get }
|
||||
static var nio_atomic_load: (UnsafeMutablePointer<AtomicWrapper>) -> Self { get }
|
||||
static var nio_atomic_store: (UnsafeMutablePointer<AtomicWrapper>, Self) -> Void { get }
|
||||
}
|
||||
#endif
|
||||
|
||||
extension Bool: NIOAtomicPrimitive {
|
||||
public typealias AtomicWrapper = catmc_nio_atomic__Bool
|
||||
|
||||
@@ -297,7 +297,6 @@ extension Atomic: @unchecked Sendable where T: Sendable {}
|
||||
/// **Do not add conformance to this protocol for arbitrary types**. Only a small range
|
||||
/// of types have appropriate atomic operations supported by the CPU, and those types
|
||||
/// already have conformances implemented.
|
||||
#if compiler(>=6.0)
|
||||
@preconcurrency
|
||||
public protocol AtomicPrimitive {
|
||||
static var atomic_create: @Sendable (Self) -> OpaquePointer { get }
|
||||
@@ -309,18 +308,6 @@ public protocol AtomicPrimitive {
|
||||
static var atomic_load: @Sendable (OpaquePointer) -> Self { get }
|
||||
static var atomic_store: @Sendable (OpaquePointer, Self) -> Void { get }
|
||||
}
|
||||
#else
|
||||
public protocol AtomicPrimitive {
|
||||
static var atomic_create: (Self) -> OpaquePointer { get }
|
||||
static var atomic_destroy: (OpaquePointer) -> Void { get }
|
||||
static var atomic_compare_and_exchange: (OpaquePointer, Self, Self) -> Bool { get }
|
||||
static var atomic_add: (OpaquePointer, Self) -> Self { get }
|
||||
static var atomic_sub: (OpaquePointer, Self) -> Self { get }
|
||||
static var atomic_exchange: (OpaquePointer, Self) -> Self { get }
|
||||
static var atomic_load: (OpaquePointer) -> Self { get }
|
||||
static var atomic_store: (OpaquePointer, Self) -> Void { get }
|
||||
}
|
||||
#endif
|
||||
|
||||
extension Bool: AtomicPrimitive {
|
||||
public static let atomic_create = catmc_atomic__Bool_create
|
||||
|
||||
@@ -323,11 +323,6 @@ public struct NIOAsyncChannel<Inbound: Sendable, Outbound: Sendable>: Sendable {
|
||||
return result
|
||||
}
|
||||
|
||||
#if compiler(>=6.0)
|
||||
// Note: Whitespace changes are used to workaround compiler bug
|
||||
// Remove when compiler version 5.10 is no longer supported.
|
||||
// https://github.com/swiftlang/swift/issues/79285
|
||||
// swift-format-ignore
|
||||
/// Provides scoped access to the inbound and outbound side of the underlying ``Channel``.
|
||||
///
|
||||
/// - Important: After this method returned the underlying ``Channel`` will be closed.
|
||||
@@ -335,7 +330,11 @@ public struct NIOAsyncChannel<Inbound: Sendable, Outbound: Sendable>: Sendable {
|
||||
/// - Parameters:
|
||||
/// - actor: actor where this function should be isolated to
|
||||
/// - body: A closure that gets scoped access to the inbound and outbound.
|
||||
public func executeThenClose<Result>(isolation actor: isolated (any Actor)? = #isolation, _ body: (_ inbound: NIOAsyncChannelInboundStream<Inbound>, _ outbound: NIOAsyncChannelOutboundWriter<Outbound>) async throws -> sending Result) async throws -> sending Result {
|
||||
public func executeThenClose<Result>(
|
||||
isolation actor: isolated (any Actor)? = #isolation,
|
||||
_ body: (_ inbound: NIOAsyncChannelInboundStream<Inbound>, _ outbound: NIOAsyncChannelOutboundWriter<Outbound>)
|
||||
async throws -> sending Result
|
||||
) async throws -> sending Result {
|
||||
let result: Result
|
||||
do {
|
||||
result = try await body(self._inbound, self._outbound)
|
||||
@@ -370,7 +369,6 @@ public struct NIOAsyncChannel<Inbound: Sendable, Outbound: Sendable>: Sendable {
|
||||
|
||||
return result
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// swift-format-ignore: AmbiguousTrailingClosureOverload
|
||||
@@ -419,11 +417,6 @@ extension NIOAsyncChannel {
|
||||
return result
|
||||
}
|
||||
|
||||
#if compiler(>=6.0)
|
||||
// Note: Whitespace changes are used to workaround compiler bug
|
||||
// Remove when compiler version 5.10 is no longer supported.
|
||||
// https://github.com/swiftlang/swift/issues/79285
|
||||
// swift-format-ignore
|
||||
/// Provides scoped access to the inbound side of the underlying ``Channel``.
|
||||
///
|
||||
/// - Important: After this method returned the underlying ``Channel`` will be closed.
|
||||
@@ -431,7 +424,10 @@ extension NIOAsyncChannel {
|
||||
/// - Parameters:
|
||||
/// - actor: actor where this function should be isolated to
|
||||
/// - body: A closure that gets scoped access to the inbound.
|
||||
public func executeThenClose<Result>(isolation actor: isolated (any Actor)? = #isolation, _ body: (_ inbound: NIOAsyncChannelInboundStream<Inbound>) async throws -> sending Result) async throws -> sending Result where Outbound == Never {
|
||||
public func executeThenClose<Result>(
|
||||
isolation actor: isolated (any Actor)? = #isolation,
|
||||
_ body: (_ inbound: NIOAsyncChannelInboundStream<Inbound>) async throws -> sending Result
|
||||
) async throws -> sending Result where Outbound == Never {
|
||||
let result: Result
|
||||
do {
|
||||
result = try await body(self._inbound)
|
||||
@@ -466,7 +462,6 @@ extension NIOAsyncChannel {
|
||||
|
||||
return result
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
extension Channel {
|
||||
|
||||
@@ -102,15 +102,9 @@ private let sysInet_pton: @convention(c) (CInt, UnsafePointer<CChar>?, UnsafeMut
|
||||
#endif
|
||||
|
||||
#if os(Android)
|
||||
#if compiler(>=6.0)
|
||||
@usableFromInline let IFF_BROADCAST: CUnsignedInt = numericCast(Android.IFF_BROADCAST.rawValue)
|
||||
@usableFromInline let IFF_POINTOPOINT: CUnsignedInt = numericCast(Android.IFF_POINTOPOINT.rawValue)
|
||||
@usableFromInline let IFF_MULTICAST: CUnsignedInt = numericCast(Android.IFF_MULTICAST.rawValue)
|
||||
#else
|
||||
@usableFromInline let IFF_BROADCAST: CUnsignedInt = numericCast(SwiftGlibc.IFF_BROADCAST.rawValue)
|
||||
@usableFromInline let IFF_POINTOPOINT: CUnsignedInt = numericCast(SwiftGlibc.IFF_POINTOPOINT.rawValue)
|
||||
@usableFromInline let IFF_MULTICAST: CUnsignedInt = numericCast(SwiftGlibc.IFF_MULTICAST.rawValue)
|
||||
#endif
|
||||
#if arch(arm)
|
||||
@usableFromInline let SO_RCVTIMEO = SO_RCVTIMEO_OLD
|
||||
@usableFromInline let SO_TIMESTAMP = SO_TIMESTAMP_OLD
|
||||
|
||||
@@ -1003,7 +1003,6 @@ extension Optional where Wrapped == ByteBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
#if compiler(>=6)
|
||||
extension ByteBuffer {
|
||||
/// Get the string at `index` from this `ByteBuffer` decoding using the UTF-8 encoding. Does not move the reader index.
|
||||
/// The selected bytes must be readable or else `nil` will be returned.
|
||||
@@ -1077,4 +1076,3 @@ extension ByteBuffer {
|
||||
try self.getUTF8ValidatedString(at: self.readerIndex, length: length)
|
||||
}
|
||||
}
|
||||
#endif // compiler(>=6)
|
||||
@@ -139,17 +139,16 @@ public final class NIOLoopBoundBox<Value>: @unchecked Sendable {
|
||||
.init(_value: value, uncheckedEventLoop: eventLoop)
|
||||
}
|
||||
|
||||
#if compiler(>=6.0)
|
||||
// Note: Whitespace changes are used to workaround compiler bug
|
||||
// Remove when compiler version 5.10 is no longer supported.
|
||||
// https://github.com/swiftlang/swift/issues/79285
|
||||
// swift-format-ignore
|
||||
/// Initialise a ``NIOLoopBoundBox`` by sending a value, validly callable off `eventLoop`.
|
||||
///
|
||||
/// Contrary to ``init(_:eventLoop:)``, this method can be called off `eventLoop` because `value` is moved into the box and can no longer be accessed outside the box.
|
||||
/// So we don't need to protect `value` itself, we just need to protect the ``NIOLoopBoundBox`` against mutations which we do because the ``value``
|
||||
/// accessors are checking that we're on `eventLoop`.
|
||||
public static func makeBoxSendingValue(_ value: sending Value, as: Value.Type = Value.self, eventLoop: EventLoop) -> NIOLoopBoundBox<Value> {
|
||||
public static func makeBoxSendingValue(
|
||||
_ value: sending Value,
|
||||
as: Value.Type = Value.self,
|
||||
eventLoop: EventLoop
|
||||
) -> NIOLoopBoundBox<Value> {
|
||||
// Here, we -- possibly surprisingly -- do not precondition being on the EventLoop. This is okay for a few
|
||||
// reasons:
|
||||
// - This function takes its value as `sending` so we don't need to worry about somebody
|
||||
@@ -159,7 +158,6 @@ public final class NIOLoopBoundBox<Value>: @unchecked Sendable {
|
||||
// - The only way to ever write (or read indeed) `self._value` is by proving to be inside the `EventLoop`.
|
||||
.init(_value: value, uncheckedEventLoop: eventLoop)
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Access the `value` with the precondition that the code is running on `eventLoop`.
|
||||
///
|
||||
|
||||
@@ -180,7 +180,7 @@ struct EventLoopCrashTests {
|
||||
NIOSingletons.groupLoopCountSuggestion = -1
|
||||
}
|
||||
|
||||
#if compiler(>=5.9) && swift(<6.2) // We only support Concurrency executor take-over on those Swift versions, as versions greater than that have not been properly tested.
|
||||
#if swift(<6.2) // We only support Concurrency executor take-over on those Swift versions, as versions greater than that have not been properly tested.
|
||||
let testInstallingSingletonMTELGAsConcurrencyExecutorWorksButOnlyOnce = CrashTest(
|
||||
regex: #"Fatal error: Must be called only once"#
|
||||
) {
|
||||
@@ -207,6 +207,6 @@ struct EventLoopCrashTests {
|
||||
// This should crash
|
||||
_ = NIOSingletons.unsafeTryInstallSingletonPosixEventLoopGroupAsConcurrencyGlobalExecutor()
|
||||
}
|
||||
#endif // compiler(>=5.9) && swift(<6.2)
|
||||
#endif // swift(<6.2)
|
||||
}
|
||||
#endif // !canImport(Darwin) || os(macOS)
|
||||
@@ -207,18 +207,20 @@ extension FileDescriptor {
|
||||
}
|
||||
|
||||
// Read and decode.
|
||||
var buffer = [CChar](repeating: 0, count: capacity)
|
||||
var buffer = [UInt8](repeating: 0, count: capacity)
|
||||
return buffer.withUnsafeMutableBufferPointer { pointer in
|
||||
self.listExtendedAttributes(pointer)
|
||||
pointer.withMemoryRebound(to: CChar.self) { pointer in
|
||||
self.listExtendedAttributes(pointer)
|
||||
}
|
||||
}.map { size in
|
||||
// The buffer contains null terminated C-strings.
|
||||
var attributes = [String]()
|
||||
var slice = buffer.prefix(size)
|
||||
while let index = slice.firstIndex(of: 0) {
|
||||
// TODO: can we do this more cheaply?
|
||||
let prefix = slice[...index]
|
||||
attributes.append(String(cString: Array(prefix)))
|
||||
slice = slice.dropFirst(prefix.count)
|
||||
let prefix = slice[..<index]
|
||||
attributes.append(String(decoding: Array(prefix), as: Unicode.UTF8.self))
|
||||
slice = slice.dropFirst(prefix.count + 1)
|
||||
}
|
||||
|
||||
return attributes
|
||||
|
||||
@@ -346,11 +346,6 @@ extension String {
|
||||
try withCString(body)
|
||||
}
|
||||
|
||||
internal init?(_platformString platformString: UnsafePointer<CInterop.PlatformChar>) {
|
||||
// Need to #if because CChar may be signed
|
||||
self.init(validatingUTF8: platformString)
|
||||
}
|
||||
|
||||
internal init(
|
||||
_errorCorrectingPlatformString platformString: UnsafePointer<CInterop.PlatformChar>
|
||||
) {
|
||||
|
||||
@@ -364,19 +364,22 @@ public enum Libc: Sendable {
|
||||
|
||||
#if !os(Android)
|
||||
static func constr(_ name: CInt) -> Result<String, Errno> {
|
||||
var buffer = [CInterop.PlatformChar](repeating: 0, count: 128)
|
||||
var buffer = [UInt8](repeating: 0, count: 128)
|
||||
|
||||
repeat {
|
||||
let result = valueOrErrno(retryOnInterrupt: false) {
|
||||
buffer.withUnsafeMutableBufferPointer { pointer in
|
||||
libc_confstr(name, pointer.baseAddress!, pointer.count)
|
||||
pointer.withMemoryRebound(to: CInterop.PlatformChar.self) { buffer in
|
||||
libc_confstr(name, buffer.baseAddress!, buffer.count)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch result {
|
||||
case let .success(length):
|
||||
if length <= buffer.count {
|
||||
return .success(String(cString: buffer))
|
||||
let nullTerminationIndex = buffer.firstIndex(of: 0) ?? buffer.endIndex
|
||||
return .success(String(decoding: buffer[..<nullTerminationIndex], as: Unicode.UTF8.self))
|
||||
} else {
|
||||
// The buffer wasn't long enough. Double and try again.
|
||||
buffer.append(contentsOf: repeatElement(0, count: buffer.capacity))
|
||||
|
||||
@@ -178,13 +178,8 @@ internal enum Epoll {
|
||||
|
||||
internal enum Linux {
|
||||
#if os(Android)
|
||||
#if compiler(>=6.0)
|
||||
static let SOCK_CLOEXEC = Android.SOCK_CLOEXEC
|
||||
static let SOCK_NONBLOCK = Android.SOCK_NONBLOCK
|
||||
#else
|
||||
static let SOCK_CLOEXEC = Glibc.SOCK_CLOEXEC
|
||||
static let SOCK_NONBLOCK = Glibc.SOCK_NONBLOCK
|
||||
#endif
|
||||
#elseif canImport(Musl)
|
||||
static let SOCK_CLOEXEC = Musl.SOCK_CLOEXEC
|
||||
static let SOCK_NONBLOCK = Musl.SOCK_NONBLOCK
|
||||
|
||||
@@ -624,7 +624,6 @@ extension NIODeadline {
|
||||
}
|
||||
|
||||
extension MultiThreadedEventLoopGroup {
|
||||
#if compiler(>=6.0)
|
||||
/// Start & automatically shut down a new ``MultiThreadedEventLoopGroup``.
|
||||
///
|
||||
/// This method allows to start & automatically dispose of a ``MultiThreadedEventLoopGroup`` following the principle of Structured Concurrency.
|
||||
@@ -660,5 +659,4 @@ extension MultiThreadedEventLoopGroup {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -44,7 +44,7 @@ extension NIOSingletons {
|
||||
return false
|
||||
#else
|
||||
// Guard between the minimum and maximum supported version for the hook
|
||||
#if compiler(>=5.9) && compiler(<6.3)
|
||||
#if compiler(<6.3)
|
||||
guard #available(macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0, *) else {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -25,18 +25,14 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
// swift-format-ignore
|
||||
// Note: Whitespace changes are used to workaround compiler bug
|
||||
// https://github.com/swiftlang/swift/issues/79285
|
||||
|
||||
#if compiler(>=6.0)
|
||||
@inlinable
|
||||
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
|
||||
internal func asyncDo<R>(
|
||||
isolation: isolated (any Actor)? = #isolation,
|
||||
// DO NOT FIX THE WHITESPACE IN THE NEXT LINE UNTIL 5.10 IS UNSUPPORTED
|
||||
// https://github.com/swiftlang/swift/issues/79285
|
||||
_ body: () async throws -> sending R, finally: sending @escaping ((any Error)?) async throws -> Void) async throws -> sending R {
|
||||
_ body: () async throws -> sending R,
|
||||
finally: sending @escaping ((any Error)?) async throws -> Void
|
||||
) async throws -> sending R {
|
||||
let result: R
|
||||
do {
|
||||
result = try await body()
|
||||
@@ -62,36 +58,3 @@ internal func asyncDo<R>(
|
||||
}.value
|
||||
return result
|
||||
}
|
||||
#else
|
||||
@inlinable
|
||||
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
|
||||
internal func asyncDo<R: Sendable>(
|
||||
_ body: () async throws -> R,
|
||||
finally: @escaping @Sendable ((any Error)?) async throws -> Void
|
||||
) async throws -> R {
|
||||
let result: R
|
||||
do {
|
||||
result = try await body()
|
||||
} catch {
|
||||
// `body` failed, we need to invoke `finally` with the `error`.
|
||||
|
||||
// This _looks_ unstructured but isn't really because we unconditionally always await the return.
|
||||
// We need to have an uncancelled task here to assure this is actually running in case we hit a
|
||||
// cancellation error.
|
||||
try await Task {
|
||||
try await finally(error)
|
||||
}.value
|
||||
throw error
|
||||
}
|
||||
|
||||
// `body` succeeded, we need to invoke `finally` with `nil` (no error).
|
||||
|
||||
// This _looks_ unstructured but isn't really because we unconditionally always await the return.
|
||||
// We need to have an uncancelled task here to assure this is actually running in case we hit a
|
||||
// cancellation error.
|
||||
try await Task {
|
||||
try await finally(nil)
|
||||
}.value
|
||||
return result
|
||||
}
|
||||
#endif
|
||||
@@ -44,15 +44,9 @@ internal typealias MMsgHdr = CNIOWindows_mmsghdr
|
||||
|
||||
#if os(Android)
|
||||
let INADDR_ANY = UInt32(0) // #define INADDR_ANY ((unsigned long int) 0x00000000)
|
||||
#if compiler(>=6.0)
|
||||
let IFF_BROADCAST: CUnsignedInt = numericCast(Android.IFF_BROADCAST.rawValue)
|
||||
let IFF_POINTOPOINT: CUnsignedInt = numericCast(Android.IFF_POINTOPOINT.rawValue)
|
||||
let IFF_MULTICAST: CUnsignedInt = numericCast(Android.IFF_MULTICAST.rawValue)
|
||||
#else
|
||||
let IFF_BROADCAST: CUnsignedInt = numericCast(SwiftGlibc.IFF_BROADCAST.rawValue)
|
||||
let IFF_POINTOPOINT: CUnsignedInt = numericCast(SwiftGlibc.IFF_POINTOPOINT.rawValue)
|
||||
let IFF_MULTICAST: CUnsignedInt = numericCast(SwiftGlibc.IFF_MULTICAST.rawValue)
|
||||
#endif
|
||||
internal typealias in_port_t = UInt16
|
||||
extension ipv6_mreq { // http://lkml.iu.edu/hypermail/linux/kernel/0106.1/0080.html
|
||||
init(ipv6mr_multiaddr: in6_addr, ipv6mr_interface: UInt32) {
|
||||
@@ -63,21 +57,12 @@ extension ipv6_mreq { // http://lkml.iu.edu/hypermail/linux/kernel/0106.1/0080.
|
||||
}
|
||||
}
|
||||
#if arch(arm)
|
||||
#if compiler(>=6.0)
|
||||
let S_IFSOCK = UInt32(Android.S_IFSOCK)
|
||||
let S_IFMT = UInt32(Android.S_IFMT)
|
||||
let S_IFREG = UInt32(Android.S_IFREG)
|
||||
let S_IFDIR = UInt32(Android.S_IFDIR)
|
||||
let S_IFLNK = UInt32(Android.S_IFLNK)
|
||||
let S_IFBLK = UInt32(Android.S_IFBLK)
|
||||
#else
|
||||
let S_IFSOCK = UInt32(SwiftGlibc.S_IFSOCK)
|
||||
let S_IFMT = UInt32(SwiftGlibc.S_IFMT)
|
||||
let S_IFREG = UInt32(SwiftGlibc.S_IFREG)
|
||||
let S_IFDIR = UInt32(SwiftGlibc.S_IFDIR)
|
||||
let S_IFLNK = UInt32(SwiftGlibc.S_IFLNK)
|
||||
let S_IFBLK = UInt32(SwiftGlibc.S_IFBLK)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ protocol ThreadOps {
|
||||
/// A Thread that executes some runnable block.
|
||||
///
|
||||
/// All methods exposed are thread-safe.
|
||||
// swift-format-ignore
|
||||
@usableFromInline
|
||||
final class NIOThread: Sendable {
|
||||
internal typealias ThreadBoxValue = (body: (NIOThread) -> Void, name: String?)
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if compiler(>=6)
|
||||
|
||||
import DequeModule
|
||||
import Synchronization
|
||||
|
||||
@@ -87,7 +85,7 @@ package func withManualTaskExecutor<T, Failure>(
|
||||
/// - Returns: The value returned by `body`.
|
||||
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
|
||||
@inlinable
|
||||
package func withManualTaskExecutor<T, Failure>(
|
||||
package func withManualTaskExecutors<T, Failure>(
|
||||
body: (ManualTaskExecutor, ManualTaskExecutor) async throws(Failure) -> T
|
||||
) async throws(Failure) -> T {
|
||||
let taskExecutor1 = ManualTaskExecutor()
|
||||
@@ -162,5 +160,3 @@ package final class ManualTaskExecutor: TaskExecutor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // compiler(>=6)
|
||||
@@ -207,18 +207,20 @@ extension FileDescriptor {
|
||||
}
|
||||
|
||||
// Read and decode.
|
||||
var buffer = [CChar](repeating: 0, count: capacity)
|
||||
var buffer = [UInt8](repeating: 0, count: capacity)
|
||||
return buffer.withUnsafeMutableBufferPointer { pointer in
|
||||
self.listExtendedAttributes(pointer)
|
||||
pointer.withMemoryRebound(to: CChar.self) { buffer in
|
||||
self.listExtendedAttributes(buffer)
|
||||
}
|
||||
}.map { size in
|
||||
// The buffer contains null terminated C-strings.
|
||||
var attributes = [String]()
|
||||
var slice = buffer.prefix(size)
|
||||
while let index = slice.firstIndex(of: 0) {
|
||||
// TODO: can we do this more cheaply?
|
||||
let prefix = slice[...index]
|
||||
attributes.append(String(cString: Array(prefix)))
|
||||
slice = slice.dropFirst(prefix.count)
|
||||
let prefix = slice[..<index]
|
||||
attributes.append(String(decoding: Array(prefix), as: UTF8.self))
|
||||
slice = slice.dropFirst(prefix.count + 1)
|
||||
}
|
||||
|
||||
return attributes
|
||||
|
||||
@@ -348,7 +348,7 @@ extension String {
|
||||
|
||||
internal init?(_platformString platformString: UnsafePointer<CInterop.PlatformChar>) {
|
||||
// Need to #if because CChar may be signed
|
||||
self.init(validatingUTF8: platformString)
|
||||
self.init(validatingCString: platformString)
|
||||
}
|
||||
|
||||
internal init(
|
||||
|
||||
@@ -364,19 +364,22 @@ public enum Libc: Sendable {
|
||||
|
||||
#if !os(Android)
|
||||
static func constr(_ name: CInt) -> Result<String, Errno> {
|
||||
var buffer = [CInterop.PlatformChar](repeating: 0, count: 128)
|
||||
var buffer = [UInt8](repeating: 0, count: 128)
|
||||
|
||||
repeat {
|
||||
let result = valueOrErrno(retryOnInterrupt: false) {
|
||||
buffer.withUnsafeMutableBufferPointer { pointer in
|
||||
libc_confstr(name, pointer.baseAddress!, pointer.count)
|
||||
pointer.withMemoryRebound(to: CInterop.PlatformChar.self) { pointer in
|
||||
libc_confstr(name, pointer.baseAddress!, pointer.count)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch result {
|
||||
case let .success(length):
|
||||
let nullTerminationIndex = buffer.firstIndex(of: 0) ?? buffer.endIndex
|
||||
if length <= buffer.count {
|
||||
return .success(String(cString: buffer))
|
||||
return .success(String(decoding: buffer[..<nullTerminationIndex], as: UTF8.self))
|
||||
} else {
|
||||
// The buffer wasn't long enough. Double and try again.
|
||||
buffer.append(contentsOf: repeatElement(0, count: buffer.capacity))
|
||||
|
||||
@@ -406,7 +406,6 @@ final class AsyncChannelTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
#if compiler(>=6.0)
|
||||
func testExecuteThenCloseFromActor() async throws {
|
||||
final actor TestActor {
|
||||
func test() async throws {
|
||||
@@ -547,7 +546,6 @@ final class AsyncChannelTests: XCTestCase {
|
||||
let r = try await actor.test()
|
||||
XCTAssertEqual(r.someMutableState, 5)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// This is unchecked Sendable since we only call this in the testing eventloop
|
||||
|
||||
@@ -607,11 +607,10 @@ final class NIOAsyncWriterTests: XCTestCase {
|
||||
self.assert(suspendCallCount: 1, yieldCallCount: 1, terminateCallCount: 1)
|
||||
}
|
||||
|
||||
#if compiler(>=6)
|
||||
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
|
||||
func testWriterFinish_AndSuspendBufferedYield() async throws {
|
||||
try await withThrowingTaskGroup(of: Void.self) { group in
|
||||
try await withManualTaskExecutor { taskExecutor1, taskExecutor2 in
|
||||
try await withManualTaskExecutors { taskExecutor1, taskExecutor2 in
|
||||
self.sink.setWritability(to: false)
|
||||
|
||||
self.delegate.didYieldHandler = { _ in
|
||||
@@ -654,7 +653,6 @@ final class NIOAsyncWriterTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // compiler(>=6)
|
||||
|
||||
func testWriterFinish_whenFinished() {
|
||||
// This tests just checks that finishing again is a no-op
|
||||
|
||||
@@ -1316,7 +1316,6 @@ class ByteBufferTest: XCTestCase {
|
||||
}
|
||||
|
||||
func testReadUTF8ValidatedString() throws {
|
||||
#if compiler(>=6)
|
||||
guard #available(macOS 15, iOS 18, tvOS 18, watchOS 11, visionOS 2, *) else {
|
||||
throw XCTSkip("'readUTF8ValidatedString' is only available in Swift 6 and later")
|
||||
}
|
||||
@@ -1327,13 +1326,9 @@ class ByteBufferTest: XCTestCase {
|
||||
XCTAssertEqual(expected, actual)
|
||||
XCTAssertEqual("", try buf.readUTF8ValidatedString(length: 0))
|
||||
XCTAssertNil(try buf.readUTF8ValidatedString(length: 1))
|
||||
#else
|
||||
throw XCTSkip("'readUTF8ValidatedString' is only available in Swift 6 and later")
|
||||
#endif // compiler(>=6)
|
||||
}
|
||||
|
||||
func testGetUTF8ValidatedString() throws {
|
||||
#if compiler(>=6)
|
||||
guard #available(macOS 15, iOS 18, tvOS 18, watchOS 11, visionOS 2, *) else {
|
||||
throw XCTSkip("'getUTF8ValidatedString' is only available in Swift 6 and later")
|
||||
}
|
||||
@@ -1342,13 +1337,9 @@ class ByteBufferTest: XCTestCase {
|
||||
buf.writeString(expected)
|
||||
let actual = try buf.getUTF8ValidatedString(at: 7, length: 7)
|
||||
XCTAssertEqual("goodbye", actual)
|
||||
#else
|
||||
throw XCTSkip("'getUTF8ValidatedString' is only available in Swift 6 and later")
|
||||
#endif // compiler(>=6)
|
||||
}
|
||||
|
||||
func testReadUTF8InvalidString() throws {
|
||||
#if compiler(>=6)
|
||||
guard #available(macOS 15, iOS 18, tvOS 18, watchOS 11, visionOS 2, *) else {
|
||||
throw XCTSkip("'readUTF8ValidatedString' is only available in Swift 6 and later")
|
||||
}
|
||||
@@ -1363,9 +1354,6 @@ class ByteBufferTest: XCTestCase {
|
||||
}
|
||||
}
|
||||
XCTAssertEqual(buf.readableBytes, 16)
|
||||
#else
|
||||
throw XCTSkip("'readUTF8ValidatedString' is only available in Swift 6 and later")
|
||||
#endif // compiler(>=6)
|
||||
}
|
||||
|
||||
func testSetIntegerBeyondCapacity() throws {
|
||||
@@ -4227,7 +4215,6 @@ extension ByteBufferTest {
|
||||
|
||||
// MARK: - peekUTF8ValidatedString Tests (available in Swift 6+)
|
||||
|
||||
#if compiler(>=6)
|
||||
func testPeekUTF8ValidatedString_Normal() throws {
|
||||
guard #available(macOS 15, iOS 18, tvOS 18, watchOS 11, visionOS 2, *) else {
|
||||
throw XCTSkip("'peekUTF8ValidatedString' is only available in Swift 6 and later")
|
||||
@@ -4267,7 +4254,6 @@ extension ByteBufferTest {
|
||||
)
|
||||
XCTAssertEqual(buffer.readerIndex, 0, "peekUTF8ValidatedString() should not advance the reader index.")
|
||||
}
|
||||
#endif
|
||||
|
||||
// MARK: - peekDispatchData Tests (available when Dispatch is imported)
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ internal func XCTAssertThrowsError<T>(
|
||||
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
|
||||
internal func XCTAssertNoThrow<T>(
|
||||
_ expression: @autoclosure () async throws -> T,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) async {
|
||||
do {
|
||||
|
||||
@@ -17,7 +17,7 @@ import XCTest
|
||||
|
||||
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
|
||||
func XCTAssertThrowsErrorAsync<R>(
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line,
|
||||
expression: () async throws -> R,
|
||||
onError: (Error) -> Void = { _ in }
|
||||
@@ -32,7 +32,7 @@ func XCTAssertThrowsErrorAsync<R>(
|
||||
|
||||
func XCTAssertThrowsFileSystemError<R>(
|
||||
_ expression: @autoclosure () throws -> R,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line,
|
||||
_ onError: (FileSystemError) -> Void = { _ in }
|
||||
) {
|
||||
@@ -51,7 +51,7 @@ func XCTAssertThrowsFileSystemError<R>(
|
||||
|
||||
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
|
||||
func XCTAssertThrowsFileSystemErrorAsync<R>(
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line,
|
||||
_ expression: () async throws -> R,
|
||||
onError: (FileSystemError) -> Void = { _ in }
|
||||
@@ -71,7 +71,7 @@ func XCTAssertThrowsFileSystemErrorAsync<R>(
|
||||
|
||||
func XCTAssertNoThrowAsync<T>(
|
||||
_ expression: @autoclosure () async throws -> T,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) async {
|
||||
do {
|
||||
|
||||
@@ -17,7 +17,7 @@ import XCTest
|
||||
|
||||
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
|
||||
func XCTAssertThrowsErrorAsync<R>(
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line,
|
||||
expression: () async throws -> R,
|
||||
onError: (Error) -> Void = { _ in }
|
||||
@@ -32,7 +32,7 @@ func XCTAssertThrowsErrorAsync<R>(
|
||||
|
||||
func XCTAssertThrowsFileSystemError<R>(
|
||||
_ expression: @autoclosure () throws -> R,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line,
|
||||
_ onError: (FileSystemError) -> Void = { _ in }
|
||||
) {
|
||||
@@ -53,7 +53,7 @@ func XCTAssertSystemCallError(
|
||||
_ error: (any Error)?,
|
||||
name: String,
|
||||
errno: Errno,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) {
|
||||
guard let systemCallError = error as? FileSystemError.SystemCallError else {
|
||||
|
||||
@@ -3293,7 +3293,7 @@ final class ChannelTests: XCTestCase {
|
||||
func _testTCP_NODELAYDefaultValue(
|
||||
value: Bool,
|
||||
_ socketAddress: SocketAddress,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) throws {
|
||||
let singleThreadedELG = MultiThreadedEventLoopGroup(numberOfThreads: 1)
|
||||
|
||||
@@ -2015,7 +2015,6 @@ final class EventLoopTest: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
#if compiler(>=6.0)
|
||||
func testStructuredConcurrencyMTELGStartStop() async throws {
|
||||
let loops = try await MultiThreadedEventLoopGroup.withEventLoopGroup(
|
||||
numberOfThreads: 3
|
||||
@@ -2069,7 +2068,6 @@ final class EventLoopTest: XCTestCase {
|
||||
}
|
||||
XCTAssertEqual("cool", actual)
|
||||
}
|
||||
#endif
|
||||
|
||||
func testRegressionSelectableEventLoopDeadlock() throws {
|
||||
let iterations = 1_000
|
||||
|
||||
@@ -75,7 +75,6 @@ final class NIOLoopBoundTests: XCTestCase {
|
||||
)
|
||||
}
|
||||
|
||||
#if compiler(>=6.0)
|
||||
func testLoopBoundBoxCanBeInitialisedWithTakingValueOffLoopAndLaterSetToValue() {
|
||||
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
|
||||
defer {
|
||||
@@ -106,7 +105,6 @@ final class NIOLoopBoundTests: XCTestCase {
|
||||
}.wait()
|
||||
)
|
||||
}
|
||||
#endif
|
||||
|
||||
func testInPlaceMutation() {
|
||||
var loopBound = NIOLoopBound(CoWValue(), eventLoop: loop)
|
||||
|
||||
@@ -390,7 +390,7 @@ private final class MockScheduledCallbackHandler: NIOScheduledCallbackHandler, S
|
||||
self.cancelCount.wrappingIncrement(by: 1, ordering: .sequentiallyConsistent)
|
||||
}
|
||||
|
||||
func assert(callbackCount: Int, cancelCount: Int, file: StaticString = #file, line: UInt = #line) {
|
||||
func assert(callbackCount: Int, cancelCount: Int, file: StaticString = #filePath, line: UInt = #line) {
|
||||
XCTAssertEqual(
|
||||
self.callbackCount.load(ordering: .sequentiallyConsistent),
|
||||
callbackCount,
|
||||
@@ -407,7 +407,7 @@ private final class MockScheduledCallbackHandler: NIOScheduledCallbackHandler, S
|
||||
)
|
||||
}
|
||||
|
||||
func waitForCallback(timeout: TimeAmount, file: StaticString = #file, line: UInt = #line) async throws {
|
||||
func waitForCallback(timeout: TimeAmount, file: StaticString = #filePath, line: UInt = #line) async throws {
|
||||
try await XCTWithTimeout(timeout, file: file, line: line) { await self.callbackStream.first { _ in true } }
|
||||
}
|
||||
}
|
||||
@@ -424,7 +424,7 @@ private final class NonSendableMockScheduledCallbackHandler: NIOScheduledCallbac
|
||||
self.cancelCount += 1
|
||||
}
|
||||
|
||||
func assert(callbackCount: Int, cancelCount: Int, file: StaticString = #file, line: UInt = #line) {
|
||||
func assert(callbackCount: Int, cancelCount: Int, file: StaticString = #filePath, line: UInt = #line) {
|
||||
XCTAssertEqual(
|
||||
self.callbackCount,
|
||||
callbackCount,
|
||||
@@ -457,7 +457,7 @@ private final class NonSendableMockScheduledCallbackHandler: NIOScheduledCallbac
|
||||
/// This function is probably a good balance of pragmatism and clarity.
|
||||
func XCTWithTimeout<Result>(
|
||||
_ timeout: TimeAmount,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line,
|
||||
operation: @escaping @Sendable () async throws -> Result
|
||||
) async throws -> Result where Result: Sendable {
|
||||
|
||||
@@ -36,13 +36,11 @@ actor EventLoopBoundActor {
|
||||
XCTAssertFalse(loop.inEventLoop)
|
||||
}
|
||||
|
||||
#if compiler(>=6.0)
|
||||
nonisolated func assumeInLoop() -> Int {
|
||||
self.assumeIsolated { actor in
|
||||
actor.counter
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@available(macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0, *)
|
||||
@@ -78,10 +76,6 @@ final class SerialExecutorTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testAssumeIsolation() async throws {
|
||||
#if compiler(<6.0)
|
||||
throw XCTSkip("Custom executors are only supported in 5.9")
|
||||
#else
|
||||
|
||||
let el = self.group.next()
|
||||
|
||||
let testActor = EventLoopBoundActor(loop: el)
|
||||
@@ -89,7 +83,6 @@ final class SerialExecutorTests: XCTestCase {
|
||||
testActor.assumeInLoop()
|
||||
}.get()
|
||||
XCTAssertEqual(result, 0)
|
||||
#endif
|
||||
}
|
||||
|
||||
override func setUp() {
|
||||
|
||||
@@ -32,7 +32,9 @@ extension System {
|
||||
|
||||
static var supportsVsockLoopback: Bool {
|
||||
#if os(Linux) || os(Android)
|
||||
guard let modules = try? String(contentsOf: URL(fileURLWithPath: "/proc/modules")) else { return false }
|
||||
guard let modules = try? String(contentsOf: URL(fileURLWithPath: "/proc/modules"), encoding: .utf8) else {
|
||||
return false
|
||||
}
|
||||
return modules.split(separator: "\n").compactMap({ $0.split(separator: " ").first }).contains("vsock_loopback")
|
||||
#else
|
||||
return false
|
||||
|
||||
@@ -428,7 +428,8 @@ class ThreadTest: XCTestCase {
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
static func joinThread(_ thread: NIOLockedValueBox<NIOThread?>, file: StaticString = #file, line: UInt = #line) {
|
||||
static func joinThread(_ thread: NIOLockedValueBox<NIOThread?>, file: StaticString = #filePath, line: UInt = #line)
|
||||
{
|
||||
if let thread = thread.withLockedValue({ $0 }) {
|
||||
thread.join()
|
||||
} else {
|
||||
|
||||
@@ -58,7 +58,7 @@ internal func XCTAssertThrowsError<T>(
|
||||
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
|
||||
internal func XCTAssertNoThrow<T>(
|
||||
_ expression: @autoclosure () async throws -> T,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) async {
|
||||
do {
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if compiler(>=6)
|
||||
|
||||
import NIOTestUtils
|
||||
import Synchronization
|
||||
import XCTest
|
||||
@@ -40,7 +38,7 @@ class ManualTaskExecutorTest: XCTestCase {
|
||||
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
|
||||
func testTwoManualTaskExecutors() async {
|
||||
await withDiscardingTaskGroup { group in
|
||||
await withManualTaskExecutor { taskExecutor1, taskExecutor2 in
|
||||
await withManualTaskExecutors { taskExecutor1, taskExecutor2 in
|
||||
let task1DidRun = Mutex(false)
|
||||
let task2DidRun = Mutex(false)
|
||||
|
||||
@@ -65,5 +63,3 @@ class ManualTaskExecutorTest: XCTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // compiler(>=6)
|
||||
Reference in new issue
Block a user