Remove `#if compiler(>=5.5)` (#2292)
### Motivation We only support Swift 5.5.2+. ### Modification Remove all `#if swift(>=5.5)` conditional compilation blocks. ### Result less branching
This commit is contained in:
parent
788b759d0b
commit
c7b4989b02
|
@ -72,7 +72,7 @@ For this reason, whenever you add new tests **you have to run a script** that ge
|
||||||
|
|
||||||
### Make sure your patch works for all supported versions of swift
|
### Make sure your patch works for all supported versions of swift
|
||||||
|
|
||||||
The CI will do this for you. You can use the docker-compose files included if you wish to check locally. Currently all versions of swift >= 5.5 are supported. For example usage of docker compose see the main [README](./README.md#an-alternative-using-docker-compose)
|
The CI will do this for you. You can use the docker-compose files included if you wish to check locally. Currently all versions of swift >= 5.5.2 are supported. For example usage of docker compose see the main [README](./README.md#an-alternative-using-docker-compose)
|
||||||
|
|
||||||
### Make sure your code is performant
|
### Make sure your code is performant
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ It's like [Netty](https://netty.io), but written for Swift.
|
||||||
|
|
||||||
The SwiftNIO project is split across multiple repositories:
|
The SwiftNIO project is split across multiple repositories:
|
||||||
|
|
||||||
Repository | NIO 2 (Swift 5.5+)
|
Repository | NIO 2 (Swift 5.5.2+)
|
||||||
--- | ---
|
--- | ---
|
||||||
[https://github.com/apple/swift-nio][repo-nio] <br> SwiftNIO core | `from: "2.0.0"`
|
[https://github.com/apple/swift-nio][repo-nio] <br> SwiftNIO core | `from: "2.0.0"`
|
||||||
[https://github.com/apple/swift-nio-ssl][repo-nio-ssl] <br> TLS (SSL) support | `from: "2.0.0"`
|
[https://github.com/apple/swift-nio-ssl][repo-nio-ssl] <br> TLS (SSL) support | `from: "2.0.0"`
|
||||||
|
@ -70,14 +70,14 @@ Redis | ✅ | ❌ | [mordil/swift-redi-stack](https://gitlab.com/Mordil/swift-re
|
||||||
|
|
||||||
This is the current version of SwiftNIO and will be supported for the foreseeable future.
|
This is the current version of SwiftNIO and will be supported for the foreseeable future.
|
||||||
|
|
||||||
The most recent versions of SwiftNIO support Swift 5.5 and newer. The minimum Swift version supported by SwiftNIO releases are detailed below:
|
The most recent versions of SwiftNIO support Swift 5.5.2 and newer. The minimum Swift version supported by SwiftNIO releases are detailed below:
|
||||||
|
|
||||||
SwiftNIO | Minimum Swift Version
|
SwiftNIO | Minimum Swift Version
|
||||||
--------------------|----------------------
|
--------------------|----------------------
|
||||||
`2.0.0 ..< 2.30.0` | 5.0
|
`2.0.0 ..< 2.30.0` | 5.0
|
||||||
`2.30.0 ..< 2.40.0` | 5.2
|
`2.30.0 ..< 2.40.0` | 5.2
|
||||||
`2.40.0 ..< 2.43.0` | 5.4
|
`2.40.0 ..< 2.43.0` | 5.4
|
||||||
`2.43.0 ...` | 5.5
|
`2.43.0 ...` | 5.5.2
|
||||||
|
|
||||||
### SwiftNIO 1
|
### 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.
|
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.
|
||||||
|
|
|
@ -18,7 +18,7 @@ team would create the following patch releases:
|
||||||
* NIO 2.42. + plus next patch release to address the issue for projects that support
|
* NIO 2.42. + plus next patch release to address the issue for projects that support
|
||||||
Swift 5.4 and later
|
Swift 5.4 and later
|
||||||
* mainline + plus next patch release to address the issue for projects that support
|
* mainline + plus next patch release to address the issue for projects that support
|
||||||
Swift 5.5 and later
|
Swift 5.5.2 and later
|
||||||
|
|
||||||
SwiftNIO 1.x is considered end of life and will not receive any security patches.
|
SwiftNIO 1.x is considered end of life and will not receive any security patches.
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
import NIOCore
|
import NIOCore
|
||||||
import NIOHTTP1
|
import NIOHTTP1
|
||||||
|
|
||||||
#if canImport(_Concurrency) && compiler(>=5.5.2)
|
|
||||||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
||||||
struct AsyncChannelIO<Request, Response> {
|
struct AsyncChannelIO<Request, Response> {
|
||||||
let channel: Channel
|
let channel: Channel
|
||||||
|
@ -39,4 +38,3 @@ struct AsyncChannelIO<Request, Response> {
|
||||||
try await self.channel.close()
|
try await self.channel.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -16,8 +16,6 @@ import NIOPosix
|
||||||
import NIOHTTP1
|
import NIOHTTP1
|
||||||
import Dispatch
|
import Dispatch
|
||||||
|
|
||||||
#if canImport(_Concurrency) && compiler(>=5.5.2)
|
|
||||||
|
|
||||||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
||||||
func makeHTTPChannel(host: String, port: Int, group: EventLoopGroup) async throws -> AsyncChannelIO<HTTPRequestHead, NIOHTTPClientResponseFull> {
|
func makeHTTPChannel(host: String, port: Int, group: EventLoopGroup) async throws -> AsyncChannelIO<HTTPRequestHead, NIOHTTPClientResponseFull> {
|
||||||
let channel = try await ClientBootstrap(group: group).connect(host: host, port: port).get()
|
let channel = try await ClientBootstrap(group: group).connect(host: host, port: port).get()
|
||||||
|
@ -76,6 +74,3 @@ if #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) {
|
||||||
dg.leave()
|
dg.leave()
|
||||||
}
|
}
|
||||||
dg.wait()
|
dg.wait()
|
||||||
#else
|
|
||||||
print("ERROR: The NIO Async Await Demo supports Swift >= 5.5.2.")
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -109,10 +109,8 @@ final class ChatHandler: ChannelInboundHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
/// access to the internal state is protected by `channelsSyncQueue`
|
/// access to the internal state is protected by `channelsSyncQueue`
|
||||||
extension ChatHandler: @unchecked Sendable {}
|
extension ChatHandler: @unchecked Sendable {}
|
||||||
#endif
|
|
||||||
|
|
||||||
// We need to share the same ChatHandler for all as it keeps track of all
|
// We need to share the same ChatHandler for all as it keeps track of all
|
||||||
// connected clients. For this ChatHandler MUST be thread-safe!
|
// connected clients. For this ChatHandler MUST be thread-safe!
|
||||||
|
|
|
@ -313,9 +313,5 @@ public final class NIOAtomic<T: NIOAtomicPrimitive> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if compiler(>=5.5) && canImport(_Concurrency)
|
|
||||||
@available(*, deprecated)
|
@available(*, deprecated)
|
||||||
extension NIOAtomic: Sendable {
|
extension NIOAtomic: Sendable {}
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -147,7 +147,5 @@ extension NIOLock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if compiler(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension NIOLock: Sendable {}
|
extension NIOLock: Sendable {}
|
||||||
extension NIOLock._Storage: Sendable {}
|
extension NIOLock._Storage: Sendable {}
|
||||||
#endif
|
|
||||||
|
|
|
@ -52,7 +52,5 @@ public struct NIOLockedValueBox<Value> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if compiler(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension NIOLockedValueBox: Sendable where Value: Sendable {}
|
extension NIOLockedValueBox: Sendable where Value: Sendable {}
|
||||||
extension NIOLockedValueBox._Storage: @unchecked Sendable {}
|
extension NIOLockedValueBox._Storage: @unchecked Sendable {}
|
||||||
#endif
|
|
||||||
|
|
|
@ -290,12 +290,6 @@ internal func debugOnly(_ body: () -> Void) {
|
||||||
assert({ body(); return true }())
|
assert({ body(); return true }())
|
||||||
}
|
}
|
||||||
|
|
||||||
#if compiler(>=5.5) && canImport(_Concurrency)
|
|
||||||
@available(*, deprecated)
|
@available(*, deprecated)
|
||||||
extension Lock: Sendable {
|
extension Lock: Sendable {}
|
||||||
|
extension ConditionLock: @unchecked Sendable {}
|
||||||
}
|
|
||||||
extension ConditionLock: @unchecked Sendable {
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,218 +0,0 @@
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// This source file is part of the SwiftNIO open source project
|
|
||||||
//
|
|
||||||
// Copyright (c) 2021 Apple Inc. and the SwiftNIO project authors
|
|
||||||
// Licensed under Apache License v2.0
|
|
||||||
//
|
|
||||||
// See LICENSE.txt for license information
|
|
||||||
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#if compiler(>=5.5) && !compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
|
|
||||||
extension EventLoopFuture {
|
|
||||||
/// Get the value/error from an `EventLoopFuture` in an `async` context.
|
|
||||||
///
|
|
||||||
/// This function can be used to bridge an `EventLoopFuture` into the `async` world. Ie. if you're in an `async`
|
|
||||||
/// function and want to get the result of this future.
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
@inlinable
|
|
||||||
public func get() async throws -> Value {
|
|
||||||
return try await withUnsafeThrowingContinuation { cont in
|
|
||||||
self.whenComplete { result in
|
|
||||||
switch result {
|
|
||||||
case .success(let value):
|
|
||||||
cont.resume(returning: value)
|
|
||||||
case .failure(let error):
|
|
||||||
cont.resume(throwing: error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension EventLoopGroup {
|
|
||||||
/// Shuts down the event loop gracefully.
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
@inlinable
|
|
||||||
public func shutdownGracefully() async throws {
|
|
||||||
return try await withCheckedThrowingContinuation { cont in
|
|
||||||
self.shutdownGracefully { error in
|
|
||||||
if let error = error {
|
|
||||||
cont.resume(throwing: error)
|
|
||||||
} else {
|
|
||||||
cont.resume()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension EventLoopPromise {
|
|
||||||
/// Complete a future with the result (or error) of the `async` function `body`.
|
|
||||||
///
|
|
||||||
/// This function can be used to bridge the `async` world into an `EventLoopPromise`.
|
|
||||||
///
|
|
||||||
/// - parameters:
|
|
||||||
/// - body: The `async` function to run.
|
|
||||||
/// - returns: A `Task` which was created to `await` the `body`.
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
@discardableResult
|
|
||||||
@inlinable
|
|
||||||
public func completeWithTask(_ body: @escaping @Sendable () async throws -> Value) -> Task<Void, Never> {
|
|
||||||
Task {
|
|
||||||
do {
|
|
||||||
let value = try await body()
|
|
||||||
self.succeed(value)
|
|
||||||
} catch {
|
|
||||||
self.fail(error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension Channel {
|
|
||||||
/// Shortcut for calling `write` and `flush`.
|
|
||||||
///
|
|
||||||
/// - parameters:
|
|
||||||
/// - data: the data to write
|
|
||||||
/// - promise: the `EventLoopPromise` that will be notified once the `write` operation completes,
|
|
||||||
/// or `nil` if not interested in the outcome of the operation.
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
@inlinable
|
|
||||||
public func writeAndFlush<T>(_ any: T) async throws {
|
|
||||||
try await self.writeAndFlush(any).get()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set `option` to `value` on this `Channel`.
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
@inlinable
|
|
||||||
public func setOption<Option: ChannelOption>(_ option: Option, value: Option.Value) async throws {
|
|
||||||
try await self.setOption(option, value: value).get()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the value of `option` for this `Channel`.
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
@inlinable
|
|
||||||
public func getOption<Option: ChannelOption>(_ option: Option) async throws -> Option.Value {
|
|
||||||
return try await self.getOption(option).get()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension ChannelOutboundInvoker {
|
|
||||||
/// Register on an `EventLoop` and so have all its IO handled.
|
|
||||||
///
|
|
||||||
/// - returns: the future which will be notified once the operation completes.
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
public func register(file: StaticString = #file, line: UInt = #line) async throws {
|
|
||||||
try await self.register(file: file, line: line).get()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Bind to a `SocketAddress`.
|
|
||||||
/// - parameters:
|
|
||||||
/// - to: the `SocketAddress` to which we should bind the `Channel`.
|
|
||||||
/// - returns: the future which will be notified once the operation completes.
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
public func bind(to address: SocketAddress, file: StaticString = #file, line: UInt = #line) async throws {
|
|
||||||
try await self.bind(to: address, file: file, line: line).get()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Connect to a `SocketAddress`.
|
|
||||||
/// - parameters:
|
|
||||||
/// - to: the `SocketAddress` to which we should connect the `Channel`.
|
|
||||||
/// - returns: the future which will be notified once the operation completes.
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
public func connect(to address: SocketAddress, file: StaticString = #file, line: UInt = #line) async throws {
|
|
||||||
try await self.connect(to: address, file: file, line: line).get()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Shortcut for calling `write` and `flush`.
|
|
||||||
///
|
|
||||||
/// - parameters:
|
|
||||||
/// - data: the data to write
|
|
||||||
/// - returns: the future which will be notified once the `write` operation completes.
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
public func writeAndFlush(_ data: NIOAny, file: StaticString = #file, line: UInt = #line) async throws {
|
|
||||||
try await self.writeAndFlush(data, file: file, line: line).get()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Close the `Channel` and so the connection if one exists.
|
|
||||||
///
|
|
||||||
/// - parameters:
|
|
||||||
/// - mode: the `CloseMode` that is used
|
|
||||||
/// - returns: the future which will be notified once the operation completes.
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
public func close(mode: CloseMode = .all, file: StaticString = #file, line: UInt = #line) async throws {
|
|
||||||
try await self.close(mode: mode, file: file, line: line).get()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Trigger a custom user outbound event which will flow through the `ChannelPipeline`.
|
|
||||||
///
|
|
||||||
/// - parameters:
|
|
||||||
/// - event: the event itself.
|
|
||||||
/// - returns: the future which will be notified once the operation completes.
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
public func triggerUserOutboundEvent(_ event: Any, file: StaticString = #file, line: UInt = #line) async throws {
|
|
||||||
try await self.triggerUserOutboundEvent(event, file: file, line: line).get()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension ChannelPipeline {
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
public func addHandler(_ handler: ChannelHandler,
|
|
||||||
name: String? = nil,
|
|
||||||
position: ChannelPipeline.Position = .last) async throws {
|
|
||||||
try await self.addHandler(handler, name: name, position: position).get()
|
|
||||||
}
|
|
||||||
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
public func removeHandler(_ handler: RemovableChannelHandler) async throws {
|
|
||||||
try await self.removeHandler(handler).get()
|
|
||||||
}
|
|
||||||
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
public func removeHandler(name: String) async throws {
|
|
||||||
try await self.removeHandler(name: name).get()
|
|
||||||
}
|
|
||||||
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
public func removeHandler(context: ChannelHandlerContext) async throws {
|
|
||||||
try await self.removeHandler(context: context).get()
|
|
||||||
}
|
|
||||||
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
@available(*, deprecated, message: "ChannelHandlerContext is not Sendable and it is therefore not safe to be used outside of its EventLoop")
|
|
||||||
public func context(handler: ChannelHandler) async throws -> ChannelHandlerContext {
|
|
||||||
return try await self.context(handler: handler).get()
|
|
||||||
}
|
|
||||||
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
@available(*, deprecated, message: "ChannelHandlerContext is not Sendable and it is therefore not safe to be used outside of its EventLoop")
|
|
||||||
public func context(name: String) async throws -> ChannelHandlerContext {
|
|
||||||
return try await self.context(name: name).get()
|
|
||||||
}
|
|
||||||
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
@available(*, deprecated, message: "ChannelHandlerContext is not Sendable and it is therefore not safe to be used outside of its EventLoop")
|
|
||||||
@inlinable
|
|
||||||
public func context<Handler: ChannelHandler>(handlerType: Handler.Type) async throws -> ChannelHandlerContext {
|
|
||||||
return try await self.context(handlerType: handlerType).get()
|
|
||||||
}
|
|
||||||
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
public func addHandlers(_ handlers: [ChannelHandler],
|
|
||||||
position: ChannelPipeline.Position = .last) async throws {
|
|
||||||
try await self.addHandlers(handlers, position: position).get()
|
|
||||||
}
|
|
||||||
|
|
||||||
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
|
|
||||||
public func addHandlers(_ handlers: ChannelHandler...,
|
|
||||||
position: ChannelPipeline.Position = .last) async throws {
|
|
||||||
try await self.addHandlers(handlers, position: position)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -12,8 +12,6 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
|
|
||||||
extension EventLoopFuture {
|
extension EventLoopFuture {
|
||||||
/// Get the value/error from an `EventLoopFuture` in an `async` context.
|
/// Get the value/error from an `EventLoopFuture` in an `async` context.
|
||||||
///
|
///
|
||||||
|
@ -332,5 +330,3 @@ struct AsyncSequenceFromIterator<AsyncIterator: AsyncIteratorProtocol>: AsyncSeq
|
||||||
self.iterator
|
self.iterator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
import DequeModule
|
import DequeModule
|
||||||
import NIOConcurrencyHelpers
|
import NIOConcurrencyHelpers
|
||||||
|
|
||||||
|
@ -329,4 +328,4 @@ extension NIOAsyncSequenceProducer {
|
||||||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
||||||
@available(*, unavailable)
|
@available(*, unavailable)
|
||||||
extension NIOAsyncSequenceProducer.AsyncIterator: Sendable {}
|
extension NIOAsyncSequenceProducer.AsyncIterator: Sendable {}
|
||||||
#endif
|
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
public enum NIOAsyncSequenceProducerBackPressureStrategies {
|
public enum NIOAsyncSequenceProducerBackPressureStrategies {
|
||||||
/// A high-low watermarked back-pressure strategy for a ``NIOAsyncSequenceProducer``.
|
/// A high-low watermarked back-pressure strategy for a ``NIOAsyncSequenceProducer``.
|
||||||
///
|
///
|
||||||
|
@ -46,4 +45,3 @@ public enum NIOAsyncSequenceProducerBackPressureStrategies {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
import Atomics
|
import Atomics
|
||||||
import DequeModule
|
import DequeModule
|
||||||
import NIOConcurrencyHelpers
|
import NIOConcurrencyHelpers
|
||||||
|
@ -1065,4 +1064,3 @@ extension NIOAsyncWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
import DequeModule
|
import DequeModule
|
||||||
import NIOConcurrencyHelpers
|
import NIOConcurrencyHelpers
|
||||||
|
|
||||||
|
@ -1059,4 +1058,3 @@ extension NIOThrowingAsyncSequenceProducer {
|
||||||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
||||||
@available(*, unavailable)
|
@available(*, unavailable)
|
||||||
extension NIOThrowingAsyncSequenceProducer.AsyncIterator: Sendable {}
|
extension NIOThrowingAsyncSequenceProducer.AsyncIterator: Sendable {}
|
||||||
#endif
|
|
||||||
|
|
|
@ -1068,9 +1068,7 @@ extension ByteBuffer: Hashable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension ByteBuffer: @unchecked Sendable {}
|
extension ByteBuffer: @unchecked Sendable {}
|
||||||
#endif
|
|
||||||
|
|
||||||
extension ByteBuffer {
|
extension ByteBuffer {
|
||||||
/// Modify this `ByteBuffer` if this `ByteBuffer` is known to uniquely own its storage.
|
/// Modify this `ByteBuffer` if this `ByteBuffer` is known to uniquely own its storage.
|
||||||
|
|
|
@ -53,9 +53,7 @@ extension ChannelOptions.Types {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension ChannelOptions.Types.ConvenienceOptionValue: Sendable where ValueType: Sendable {}
|
extension ChannelOptions.Types.ConvenienceOptionValue: Sendable where ValueType: Sendable {}
|
||||||
#endif
|
|
||||||
|
|
||||||
extension ChannelOptions.Types.ConvenienceOptionValue where ValueType == () {
|
extension ChannelOptions.Types.ConvenienceOptionValue where ValueType == () {
|
||||||
/// Convenience method working with bool options as bool values for set.
|
/// Convenience method working with bool options as bool values for set.
|
||||||
|
|
|
@ -2186,11 +2186,7 @@ public struct _NIOEventLoopFutureIdentifier: Hashable, NIOSendable {
|
||||||
// EventLoopPromise is a reference type, but by its very nature is Sendable.
|
// EventLoopPromise is a reference type, but by its very nature is Sendable.
|
||||||
extension EventLoopPromise: NIOSendable { }
|
extension EventLoopPromise: NIOSendable { }
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
|
|
||||||
// EventLoopFuture is a reference type, but it is Sendable. However, we enforce
|
// EventLoopFuture is a reference type, but it is Sendable. However, we enforce
|
||||||
// that by way of the guarantees of the EventLoop protocol, so the compiler cannot
|
// that by way of the guarantees of the EventLoop protocol, so the compiler cannot
|
||||||
// check it.
|
// check it.
|
||||||
extension EventLoopFuture: @unchecked NIOSendable { }
|
extension EventLoopFuture: @unchecked NIOSendable { }
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -348,9 +348,7 @@ public struct NIONetworkDevice {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension NIONetworkDevice: @unchecked Sendable {}
|
extension NIONetworkDevice: @unchecked Sendable {}
|
||||||
#endif
|
|
||||||
|
|
||||||
extension NIONetworkDevice {
|
extension NIONetworkDevice {
|
||||||
fileprivate final class Backing {
|
fileprivate final class Backing {
|
||||||
|
|
|
@ -38,9 +38,7 @@ struct UnsafeTransfer<Wrapped> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension UnsafeTransfer: @unchecked Sendable {}
|
extension UnsafeTransfer: @unchecked Sendable {}
|
||||||
#endif
|
|
||||||
|
|
||||||
extension UnsafeTransfer: Equatable where Wrapped: Equatable {}
|
extension UnsafeTransfer: Equatable where Wrapped: Equatable {}
|
||||||
extension UnsafeTransfer: Hashable where Wrapped: Hashable {}
|
extension UnsafeTransfer: Hashable where Wrapped: Hashable {}
|
||||||
|
@ -58,6 +56,6 @@ final class UnsafeMutableTransferBox<Wrapped> {
|
||||||
self.wrappedValue = wrappedValue
|
self.wrappedValue = wrappedValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension UnsafeMutableTransferBox: @unchecked Sendable {}
|
extension UnsafeMutableTransferBox: @unchecked Sendable {}
|
||||||
#endif
|
|
||||||
|
|
|
@ -560,15 +560,8 @@ extension SocketAddress: Equatable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if compiler(>=5.5.2)
|
|
||||||
extension SocketAddress.IPv4Address: Sendable {}
|
extension SocketAddress.IPv4Address: Sendable {}
|
||||||
extension SocketAddress.IPv6Address: Sendable {}
|
extension SocketAddress.IPv6Address: Sendable {}
|
||||||
#elseif compiler(>=5.5)
|
|
||||||
// Implicit conformance of tuples to Sendable interacts poorly with conditional conformance of Sendable in Swift <=5.5.1
|
|
||||||
// https://github.com/apple/swift/issues/57346
|
|
||||||
extension SocketAddress.IPv4Address: @unchecked Sendable {}
|
|
||||||
extension SocketAddress.IPv6Address: @unchecked Sendable {}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// We define an extension on `SocketAddress` that gives it an elementwise hashable conformance, using
|
/// We define an extension on `SocketAddress` that gives it an elementwise hashable conformance, using
|
||||||
/// only the elements defined on the structure in their man pages (excluding lengths).
|
/// only the elements defined on the structure in their man pages (excluding lengths).
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
import NIOConcurrencyHelpers
|
import NIOConcurrencyHelpers
|
||||||
import NIOCore
|
import NIOCore
|
||||||
|
|
||||||
|
@ -563,5 +563,3 @@ extension NIOAsyncTestingChannel.LeftOverState: @unchecked Sendable { }
|
||||||
|
|
||||||
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
|
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
|
||||||
extension NIOAsyncTestingChannel.BufferState: @unchecked Sendable { }
|
extension NIOAsyncTestingChannel.BufferState: @unchecked Sendable { }
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
import Atomics
|
import Atomics
|
||||||
import Dispatch
|
import Dispatch
|
||||||
import _NIODataStructures
|
import _NIODataStructures
|
||||||
|
@ -375,5 +375,3 @@ private class PromiseCreationStore {
|
||||||
precondition(self.promiseCreationStore.isEmpty, "NIOAsyncTestingEventLoop freed with uncompleted promises!")
|
precondition(self.promiseCreationStore.isEmpty, "NIOAsyncTestingEventLoop freed with uncompleted promises!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -325,9 +325,7 @@ public final class HTTPServerUpgradeHandler: ChannelInboundHandler, RemovableCha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension HTTPServerUpgradeHandler: @unchecked Sendable {}
|
extension HTTPServerUpgradeHandler: @unchecked Sendable {}
|
||||||
#endif
|
|
||||||
|
|
||||||
extension HTTPServerUpgradeHandler {
|
extension HTTPServerUpgradeHandler {
|
||||||
/// The state of the upgrade handler.
|
/// The state of the upgrade handler.
|
||||||
|
|
|
@ -123,9 +123,7 @@ public struct HTTPRequestHead: Equatable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension HTTPRequestHead: @unchecked Sendable {}
|
extension HTTPRequestHead: @unchecked Sendable {}
|
||||||
#endif
|
|
||||||
|
|
||||||
/// The parts of a complete HTTP message, either request or response.
|
/// The parts of a complete HTTP message, either request or response.
|
||||||
///
|
///
|
||||||
|
@ -139,9 +137,7 @@ public enum HTTPPart<HeadT: Equatable, BodyT: Equatable> {
|
||||||
case end(HTTPHeaders?)
|
case end(HTTPHeaders?)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension HTTPPart: Sendable where HeadT: Sendable, BodyT: Sendable {}
|
extension HTTPPart: Sendable where HeadT: Sendable, BodyT: Sendable {}
|
||||||
#endif
|
|
||||||
|
|
||||||
extension HTTPPart: Equatable {}
|
extension HTTPPart: Equatable {}
|
||||||
|
|
||||||
|
@ -236,9 +232,7 @@ public struct HTTPResponseHead: Equatable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension HTTPResponseHead: @unchecked Sendable {}
|
extension HTTPResponseHead: @unchecked Sendable {}
|
||||||
#endif
|
|
||||||
|
|
||||||
extension HTTPResponseHead {
|
extension HTTPResponseHead {
|
||||||
/// Determines if the head is purely informational. If a head is informational another head will follow this
|
/// Determines if the head is purely informational. If a head is informational another head will follow this
|
||||||
|
@ -497,13 +491,7 @@ public struct HTTPHeaders: CustomStringConvertible, ExpressibleByDictionaryLiter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if compiler(>=5.5.2)
|
|
||||||
extension HTTPHeaders: Sendable {}
|
extension HTTPHeaders: Sendable {}
|
||||||
#elseif compiler(>=5.5)
|
|
||||||
// Implicit conformance of tuples to Sendable interacts poorly with conditional conformance of Sendable in Swift <=5.5.1
|
|
||||||
// https://github.com/apple/swift/issues/57346
|
|
||||||
extension HTTPHeaders: @unchecked Sendable {}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extension HTTPHeaders {
|
extension HTTPHeaders {
|
||||||
|
|
||||||
|
|
|
@ -378,9 +378,7 @@ public final class NIOHTTPClientUpgradeHandler: ChannelDuplexHandler, RemovableC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension NIOHTTPClientUpgradeHandler: @unchecked Sendable {}
|
extension NIOHTTPClientUpgradeHandler: @unchecked Sendable {}
|
||||||
#endif
|
|
||||||
|
|
||||||
extension NIOHTTPClientUpgradeHandler {
|
extension NIOHTTPClientUpgradeHandler {
|
||||||
/// The state of the upgrade handler.
|
/// The state of the upgrade handler.
|
||||||
|
|
|
@ -30,7 +30,6 @@ func measureAndPrint<B: Benchmark>(desc: String, benchmark bench: B) throws {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
||||||
protocol AsyncBenchmark: AnyObject, Sendable {
|
protocol AsyncBenchmark: AnyObject, Sendable {
|
||||||
func setUp() async throws
|
func setUp() async throws
|
||||||
|
@ -57,4 +56,3 @@ func measureAndPrint<B: AsyncBenchmark>(desc: String, benchmark bench: B) throws
|
||||||
|
|
||||||
group.wait()
|
group.wait()
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
import NIOCore
|
import NIOCore
|
||||||
import DequeModule
|
import DequeModule
|
||||||
import Atomics
|
import Atomics
|
||||||
|
@ -54,4 +53,3 @@ final class NIOAsyncWriterSingleWritesBenchmark: AsyncBenchmark, @unchecked Send
|
||||||
return self.delegate.counter.load(ordering: .sequentiallyConsistent)
|
return self.delegate.counter.load(ordering: .sequentiallyConsistent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -62,7 +62,6 @@ public func measureAndPrint(desc: String, fn: () throws -> Int) rethrows -> Void
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
||||||
public func measure(_ fn: () async throws -> Int) async rethrows -> [Double] {
|
public func measure(_ fn: () async throws -> Int) async rethrows -> [Double] {
|
||||||
func measureOne(_ fn: () async throws -> Int) async rethrows -> Double {
|
func measureOne(_ fn: () async throws -> Int) async rethrows -> Double {
|
||||||
|
@ -91,7 +90,6 @@ public func measureAndPrint(desc: String, fn: () async throws -> Int) async reth
|
||||||
print("skipping '\(desc)', limit set = \(limitSet)")
|
print("skipping '\(desc)', limit set = \(limitSet)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// MARK: Utilities
|
// MARK: Utilities
|
||||||
|
|
||||||
|
@ -1085,7 +1083,6 @@ try measureAndPrint(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
if #available(macOS 10.15, *) {
|
if #available(macOS 10.15, *) {
|
||||||
try measureAndPrint(
|
try measureAndPrint(
|
||||||
desc: "asyncwriter_single_writes_1M_times",
|
desc: "asyncwriter_single_writes_1M_times",
|
||||||
|
@ -1094,4 +1091,3 @@ if #available(macOS 10.15, *) {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -358,9 +358,7 @@ public final class MultiThreadedEventLoopGroup: EventLoopGroup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension MultiThreadedEventLoopGroup: @unchecked Sendable {}
|
extension MultiThreadedEventLoopGroup: @unchecked Sendable {}
|
||||||
#endif
|
|
||||||
|
|
||||||
extension MultiThreadedEventLoopGroup: CustomStringConvertible {
|
extension MultiThreadedEventLoopGroup: CustomStringConvertible {
|
||||||
public var description: String {
|
public var description: String {
|
||||||
|
|
|
@ -252,9 +252,7 @@ public final class NIOThreadPool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension NIOThreadPool: @unchecked Sendable {}
|
extension NIOThreadPool: @unchecked Sendable {}
|
||||||
#endif
|
|
||||||
|
|
||||||
extension NIOThreadPool {
|
extension NIOThreadPool {
|
||||||
|
|
||||||
|
|
|
@ -228,9 +228,7 @@ public final class ThreadSpecificVariable<Value: AnyObject> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension ThreadSpecificVariable: @unchecked Sendable where Value: Sendable {}
|
extension ThreadSpecificVariable: @unchecked Sendable where Value: Sendable {}
|
||||||
#endif
|
|
||||||
|
|
||||||
extension NIOThread: Equatable {
|
extension NIOThread: Equatable {
|
||||||
static func ==(lhs: NIOThread, rhs: NIOThread) -> Bool {
|
static func ==(lhs: NIOThread, rhs: NIOThread) -> Bool {
|
||||||
|
|
|
@ -209,7 +209,6 @@ extension ByteToMessageDecoderVerifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
/// `VerificationError` conforms to `Error` and therefore needs to conform to `Sendable` too.
|
/// `VerificationError` conforms to `Error` and therefore needs to conform to `Sendable` too.
|
||||||
/// `VerificationError` has a stored property `errorCode` of type `ErrorCode` which can store `NIOAny` which is not and can not be `Sendable`.
|
/// `VerificationError` has a stored property `errorCode` of type `ErrorCode` which can store `NIOAny` which is not and can not be `Sendable`.
|
||||||
/// In addtion, `ErrorCode` can also store a user defined `OutputType` which is not required to be `Sendable` but we could require it to be `Sendable`.
|
/// In addtion, `ErrorCode` can also store a user defined `OutputType` which is not required to be `Sendable` but we could require it to be `Sendable`.
|
||||||
|
@ -220,4 +219,3 @@ extension ByteToMessageDecoderVerifier {
|
||||||
/// it sound like the best option to just stick to the conformances we already have and **not** lie twice by making `VerificationError` conform to `Sendable` too.
|
/// it sound like the best option to just stick to the conformances we already have and **not** lie twice by making `VerificationError` conform to `Sendable` too.
|
||||||
/// Note that this still allows us to adopt `Sendable` for `ErrorCode` later if we change our opinion.
|
/// Note that this still allows us to adopt `Sendable` for `ErrorCode` later if we change our opinion.
|
||||||
extension ByteToMessageDecoderVerifier.VerificationError: @unchecked Sendable {}
|
extension ByteToMessageDecoderVerifier.VerificationError: @unchecked Sendable {}
|
||||||
#endif
|
|
||||||
|
|
|
@ -46,9 +46,7 @@ private final class BlockingQueue<Element> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension BlockingQueue: @unchecked Sendable where Element: Sendable {}
|
extension BlockingQueue: @unchecked Sendable where Element: Sendable {}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
private final class WebServerHandler: ChannelDuplexHandler {
|
private final class WebServerHandler: ChannelDuplexHandler {
|
||||||
|
|
|
@ -323,9 +323,7 @@ public struct WebSocketFrame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension WebSocketFrame: @unchecked Sendable {}
|
extension WebSocketFrame: @unchecked Sendable {}
|
||||||
#endif
|
|
||||||
|
|
||||||
extension WebSocketFrame: Equatable {}
|
extension WebSocketFrame: Equatable {}
|
||||||
|
|
||||||
|
|
|
@ -264,9 +264,5 @@ extension Heap: Sequence {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
|
|
||||||
extension Heap: Sendable where Element: Sendable {}
|
extension Heap: Sendable where Element: Sendable {}
|
||||||
extension HeapIterator: Sendable where Element: Sendable {}
|
extension HeapIterator: Sendable where Element: Sendable {}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -102,9 +102,5 @@ extension PriorityQueue: CustomStringConvertible {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
|
|
||||||
extension PriorityQueue: Sendable where Element: Sendable {}
|
extension PriorityQueue: Sendable where Element: Sendable {}
|
||||||
extension PriorityQueue.Iterator: Sendable where Element: Sendable {}
|
extension PriorityQueue.Iterator: Sendable where Element: Sendable {}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ fileprivate struct TestCase {
|
||||||
|
|
||||||
final class AsyncSequenceCollectTests: XCTestCase {
|
final class AsyncSequenceCollectTests: XCTestCase {
|
||||||
func testAsyncSequenceCollect() {
|
func testAsyncSequenceCollect() {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return }
|
||||||
XCTAsyncTest(timeout: 5) {
|
XCTAsyncTest(timeout: 5) {
|
||||||
let testCases = [
|
let testCases = [
|
||||||
|
@ -159,12 +158,9 @@ final class AsyncSequenceCollectTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
|
|
||||||
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
|
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
|
||||||
struct AsyncSequenceFromSyncSequence<Wrapped: Sequence>: AsyncSequence {
|
struct AsyncSequenceFromSyncSequence<Wrapped: Sequence>: AsyncSequence {
|
||||||
typealias Element = Wrapped.Element
|
typealias Element = Wrapped.Element
|
||||||
|
@ -189,5 +185,3 @@ extension Sequence {
|
||||||
.init(wrapped: self)
|
.init(wrapped: self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
import NIOCore
|
import NIOCore
|
||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
|
@ -58,4 +57,3 @@ final class NIOAsyncSequenceProducerBackPressureStrategiesHighLowWatermarkTests:
|
||||||
XCTAssertFalse(self.strategy.didConsume(bufferDepth: 5))
|
XCTAssertFalse(self.strategy.didConsume(bufferDepth: 5))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
import NIOCore
|
import NIOCore
|
||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
final class MockNIOElementStreamBackPressureStrategy: NIOAsyncSequenceProducerBackPressureStrategy, @unchecked Sendable {
|
final class MockNIOElementStreamBackPressureStrategy: NIOAsyncSequenceProducerBackPressureStrategy, @unchecked Sendable {
|
||||||
var didYieldCallCount = 0
|
var didYieldCallCount = 0
|
||||||
var didYieldHandler: ((Int) -> Bool)?
|
var didYieldHandler: ((Int) -> Bool)?
|
||||||
|
@ -622,5 +621,3 @@ fileprivate func XCTAssertEqualWithoutAutoclosure<T>(
|
||||||
let result = expression1 == expression2
|
let result = expression1 == expression2
|
||||||
XCTAssertTrue(result, message(), file: file, line: line)
|
XCTAssertTrue(result, message(), file: file, line: line)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
import DequeModule
|
import DequeModule
|
||||||
import NIOCore
|
import NIOCore
|
||||||
import XCTest
|
import XCTest
|
||||||
|
@ -529,4 +528,3 @@ final class NIOAsyncWriterTests: XCTestCase {
|
||||||
XCTAssertEqual(self.delegate.didTerminateCallCount, 1)
|
XCTAssertEqual(self.delegate.didTerminateCallCount, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
import NIOCore
|
import NIOCore
|
||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
final class NIOThrowingAsyncSequenceProducerTests: XCTestCase {
|
final class NIOThrowingAsyncSequenceProducerTests: XCTestCase {
|
||||||
private var backPressureStrategy: MockNIOElementStreamBackPressureStrategy!
|
private var backPressureStrategy: MockNIOElementStreamBackPressureStrategy!
|
||||||
private var delegate: MockNIOBackPressuredStreamSourceDelegate!
|
private var delegate: MockNIOBackPressuredStreamSourceDelegate!
|
||||||
|
@ -726,5 +725,3 @@ fileprivate func XCTAssertEqualWithoutAutoclosure<T>(
|
||||||
let result = expression1 == expression2
|
let result = expression1 == expression2
|
||||||
XCTAssertTrue(result, message(), file: file, line: line)
|
XCTAssertTrue(result, message(), file: file, line: line)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
extension XCTestCase {
|
extension XCTestCase {
|
||||||
|
@ -116,4 +116,3 @@ internal func XCTAssertNoThrowWithResult<Result>(
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ import NIOCore
|
||||||
|
|
||||||
class AsyncTestingChannelTests: XCTestCase {
|
class AsyncTestingChannelTests: XCTestCase {
|
||||||
func testSingleHandlerInit() throws {
|
func testSingleHandlerInit() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
class Handler: ChannelInboundHandler {
|
class Handler: ChannelInboundHandler {
|
||||||
|
@ -29,13 +28,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
let channel = await NIOAsyncTestingChannel(handler: Handler())
|
let channel = await NIOAsyncTestingChannel(handler: Handler())
|
||||||
XCTAssertNoThrow(try channel.pipeline.handler(type: Handler.self).wait())
|
XCTAssertNoThrow(try channel.pipeline.handler(type: Handler.self).wait())
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testEmptyInit() throws {
|
func testEmptyInit() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
|
|
||||||
class Handler: ChannelInboundHandler {
|
class Handler: ChannelInboundHandler {
|
||||||
|
@ -47,13 +42,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
XCTAssertEqual(e as? ChannelPipelineError, .notFound)
|
XCTAssertEqual(e as? ChannelPipelineError, .notFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testMultipleHandlerInit() throws {
|
func testMultipleHandlerInit() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
class Handler: ChannelInboundHandler, RemovableChannelHandler {
|
class Handler: ChannelInboundHandler, RemovableChannelHandler {
|
||||||
|
@ -77,13 +68,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
XCTAssertNoThrow(XCTAssertEqual(try channel.pipeline.handler(type: Handler.self).wait().identifier, "2"))
|
XCTAssertNoThrow(XCTAssertEqual(try channel.pipeline.handler(type: Handler.self).wait().identifier, "2"))
|
||||||
XCTAssertNoThrow(try channel.pipeline.removeHandler(name: "handler2").wait())
|
XCTAssertNoThrow(try channel.pipeline.removeHandler(name: "handler2").wait())
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testWriteOutboundByteBuffer() throws {
|
func testWriteOutboundByteBuffer() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -104,13 +91,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
XCTAssertNoThrow(XCTAssertNil(nextOutboundRead))
|
XCTAssertNoThrow(XCTAssertNil(nextOutboundRead))
|
||||||
XCTAssertNoThrow(XCTAssertNil(nextInboundRead))
|
XCTAssertNoThrow(XCTAssertNil(nextInboundRead))
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testWriteOutboundByteBufferMultipleTimes() throws {
|
func testWriteOutboundByteBufferMultipleTimes() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -131,13 +114,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
try await XCTAsyncAssertNil(await channel.readOutbound(as: ByteBuffer.self))
|
try await XCTAsyncAssertNil(await channel.readOutbound(as: ByteBuffer.self))
|
||||||
try await XCTAsyncAssertNil(await channel.readInbound(as: ByteBuffer.self))
|
try await XCTAsyncAssertNil(await channel.readInbound(as: ByteBuffer.self))
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testWriteInboundByteBuffer() throws {
|
func testWriteInboundByteBuffer() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -150,13 +129,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
try await XCTAsyncAssertNil(await channel.readInbound(as: ByteBuffer.self))
|
try await XCTAsyncAssertNil(await channel.readInbound(as: ByteBuffer.self))
|
||||||
try await XCTAsyncAssertNil(await channel.readOutbound(as: ByteBuffer.self))
|
try await XCTAsyncAssertNil(await channel.readOutbound(as: ByteBuffer.self))
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testWriteInboundByteBufferMultipleTimes() throws {
|
func testWriteInboundByteBufferMultipleTimes() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -177,13 +152,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
try await XCTAsyncAssertNil(await channel.readInbound(as: ByteBuffer.self))
|
try await XCTAsyncAssertNil(await channel.readInbound(as: ByteBuffer.self))
|
||||||
try await XCTAsyncAssertNil(await channel.readOutbound(as: ByteBuffer.self))
|
try await XCTAsyncAssertNil(await channel.readOutbound(as: ByteBuffer.self))
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testWriteInboundByteBufferReThrow() throws {
|
func testWriteInboundByteBufferReThrow() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -193,13 +164,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
}
|
}
|
||||||
try await XCTAsyncAssertTrue(await channel.finish().isClean)
|
try await XCTAsyncAssertTrue(await channel.finish().isClean)
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testWriteOutboundByteBufferReThrow() throws {
|
func testWriteOutboundByteBufferReThrow() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -209,13 +176,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
}
|
}
|
||||||
try await XCTAsyncAssertTrue(await channel.finish().isClean)
|
try await XCTAsyncAssertTrue(await channel.finish().isClean)
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testReadOutboundWrongTypeThrows() throws {
|
func testReadOutboundWrongTypeThrows() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -230,13 +193,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
XCTFail()
|
XCTFail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testReadInboundWrongTypeThrows() throws {
|
func testReadInboundWrongTypeThrows() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -251,13 +210,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
XCTFail()
|
XCTFail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testWrongTypesWithFastpathTypes() throws {
|
func testWrongTypesWithFastpathTypes() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -306,13 +261,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
await check(expected: ByteBuffer.self, actual: AddressedEnvelope<ByteBuffer>.self)
|
await check(expected: ByteBuffer.self, actual: AddressedEnvelope<ByteBuffer>.self)
|
||||||
await check(expected: AddressedEnvelope<ByteBuffer>.self, actual: IOData.self)
|
await check(expected: AddressedEnvelope<ByteBuffer>.self, actual: IOData.self)
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCloseMultipleTimesThrows() throws {
|
func testCloseMultipleTimesThrows() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -326,13 +277,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
// Nothing to do here.
|
// Nothing to do here.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCloseOnInactiveIsOk() throws {
|
func testCloseOnInactiveIsOk() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -343,13 +290,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
// channelInactive should fire only once.
|
// channelInactive should fire only once.
|
||||||
XCTAssertEqual(inactiveHandler.inactiveNotifications, 1)
|
XCTAssertEqual(inactiveHandler.inactiveNotifications, 1)
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testEmbeddedLifecycle() throws {
|
func testEmbeddedLifecycle() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let handler = ChannelLifecycleHandler()
|
let handler = ChannelLifecycleHandler()
|
||||||
|
@ -368,9 +311,6 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
XCTAssertEqual(handler.currentState, .unregistered)
|
XCTAssertEqual(handler.currentState, .unregistered)
|
||||||
XCTAssertFalse(channel.isActive)
|
XCTAssertFalse(channel.isActive)
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ExceptionThrowingInboundHandler : ChannelInboundHandler {
|
private final class ExceptionThrowingInboundHandler : ChannelInboundHandler {
|
||||||
|
@ -401,7 +341,6 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testEmbeddedChannelAndPipelineAndChannelCoreShareTheEventLoop() throws {
|
func testEmbeddedChannelAndPipelineAndChannelCoreShareTheEventLoop() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -410,13 +349,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
XCTAssert(pipelineEventLoop === (channel._channelCore as! EmbeddedChannelCore).eventLoop)
|
XCTAssert(pipelineEventLoop === (channel._channelCore as! EmbeddedChannelCore).eventLoop)
|
||||||
try await XCTAsyncAssertTrue(await channel.finish().isClean)
|
try await XCTAsyncAssertTrue(await channel.finish().isClean)
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testSendingAnythingOnEmbeddedChannel() throws {
|
func testSendingAnythingOnEmbeddedChannel() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -435,13 +370,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
try await channel.writeAndFlush(IOData.fileRegion(fileRegion))
|
try await channel.writeAndFlush(IOData.fileRegion(fileRegion))
|
||||||
try await channel.writeAndFlush(AddressedEnvelope(remoteAddress: socketAddress, data: buffer))
|
try await channel.writeAndFlush(AddressedEnvelope(remoteAddress: socketAddress, data: buffer))
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testActiveWhenConnectPromiseFiresAndInactiveWhenClosePromiseFires() throws {
|
func testActiveWhenConnectPromiseFiresAndInactiveWhenClosePromiseFires() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -461,13 +392,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
channel.close(promise: closePromise)
|
channel.close(promise: closePromise)
|
||||||
try await closePromise.futureResult.get()
|
try await closePromise.futureResult.get()
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testWriteWithoutFlushDoesNotWrite() throws {
|
func testWriteWithoutFlushDoesNotWrite() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -481,13 +408,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
XCTAssertTrue(writeFuture.isFulfilled)
|
XCTAssertTrue(writeFuture.isFulfilled)
|
||||||
try await XCTAsyncAssertTrue(await channel.finish().isClean)
|
try await XCTAsyncAssertTrue(await channel.finish().isClean)
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testSetLocalAddressAfterSuccessfulBind() throws {
|
func testSetLocalAddressAfterSuccessfulBind() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
|
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -499,13 +422,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
}
|
}
|
||||||
try bindPromise.futureResult.wait()
|
try bindPromise.futureResult.wait()
|
||||||
|
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testSetRemoteAddressAfterSuccessfulConnect() throws {
|
func testSetRemoteAddressAfterSuccessfulConnect() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
|
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -517,13 +436,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
}
|
}
|
||||||
try connectPromise.futureResult.wait()
|
try connectPromise.futureResult.wait()
|
||||||
|
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testUnprocessedOutboundUserEventFailsOnEmbeddedChannel() throws {
|
func testUnprocessedOutboundUserEventFailsOnEmbeddedChannel() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
|
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -535,13 +450,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testEmbeddedChannelWritabilityIsWritable() throws {
|
func testEmbeddedChannelWritabilityIsWritable() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
|
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -552,13 +463,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
XCTAssertFalse(channel.isWritable)
|
XCTAssertFalse(channel.isWritable)
|
||||||
XCTAssertFalse(opaqueChannel.isWritable)
|
XCTAssertFalse(opaqueChannel.isWritable)
|
||||||
|
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testFinishWithRecursivelyScheduledTasks() throws {
|
func testFinishWithRecursivelyScheduledTasks() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
|
@ -576,13 +483,9 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
_ = try await channel.finish()
|
_ = try await channel.finish()
|
||||||
XCTAssertEqual(invocations.load(), 1)
|
XCTAssertEqual(invocations.load(), 1)
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testSyncOptionsAreSupported() throws {
|
func testSyncOptionsAreSupported() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
try channel.testingEventLoop.submit {
|
try channel.testingEventLoop.submit {
|
||||||
|
@ -592,26 +495,18 @@ class AsyncTestingChannelTests: XCTestCase {
|
||||||
XCTAssertEqual(try options?.getOption(ChannelOptions.autoRead), true)
|
XCTAssertEqual(try options?.getOption(ChannelOptions.autoRead), true)
|
||||||
// (Setting options isn't supported.)
|
// (Setting options isn't supported.)
|
||||||
}.wait()
|
}.wait()
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testSecondFinishThrows() throws {
|
func testSecondFinishThrows() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let channel = NIOAsyncTestingChannel()
|
let channel = NIOAsyncTestingChannel()
|
||||||
_ = try await channel.finish()
|
_ = try await channel.finish()
|
||||||
await XCTAsyncAssertThrowsError(try await channel.finish())
|
await XCTAsyncAssertThrowsError(try await channel.finish())
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
fileprivate func XCTAsyncAssertTrue(_ predicate: @autoclosure () async throws -> Bool, file: StaticString = #file, line: UInt = #line) async rethrows {
|
fileprivate func XCTAsyncAssertTrue(_ predicate: @autoclosure () async throws -> Bool, file: StaticString = #file, line: UInt = #line) async rethrows {
|
||||||
let result = try await predicate()
|
let result = try await predicate()
|
||||||
XCTAssertTrue(result, file: file, line: line)
|
XCTAssertTrue(result, file: file, line: line)
|
||||||
|
@ -656,4 +551,3 @@ final class AtomicCounter: @unchecked Sendable {
|
||||||
self.baseCounter.load(ordering: .relaxed)
|
self.baseCounter.load(ordering: .relaxed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ private class EmbeddedTestError: Error { }
|
||||||
|
|
||||||
final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
func testExecuteDoesNotImmediatelyRunTasks() throws {
|
func testExecuteDoesNotImmediatelyRunTasks() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let callbackRan = ManagedAtomic(false)
|
let callbackRan = ManagedAtomic(false)
|
||||||
|
@ -37,13 +36,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
await loop.run()
|
await loop.run()
|
||||||
XCTAssertTrue(callbackRan.load(ordering: .relaxed))
|
XCTAssertTrue(callbackRan.load(ordering: .relaxed))
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testExecuteWillRunAllTasks() throws {
|
func testExecuteWillRunAllTasks() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let runCount = ManagedAtomic(0)
|
let runCount = ManagedAtomic(0)
|
||||||
|
@ -60,13 +55,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
XCTAssertEqual(runCount.load(ordering: .relaxed), 3)
|
XCTAssertEqual(runCount.load(ordering: .relaxed), 3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testExecuteWillRunTasksAddedRecursively() throws {
|
func testExecuteWillRunTasksAddedRecursively() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let sentinel = ManagedAtomic(0)
|
let sentinel = ManagedAtomic(0)
|
||||||
|
@ -96,13 +87,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
XCTAssertEqual(sentinel.load(ordering: .relaxed), 3)
|
XCTAssertEqual(sentinel.load(ordering: .relaxed), 3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testExecuteRunsImmediately() throws {
|
func testExecuteRunsImmediately() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let callbackRan = ManagedAtomic(false)
|
let callbackRan = ManagedAtomic(false)
|
||||||
|
@ -121,13 +108,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
XCTAssertFalse(callbackRan.load(ordering: .relaxed))
|
XCTAssertFalse(callbackRan.load(ordering: .relaxed))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testTasksScheduledAfterRunDontRun() throws {
|
func testTasksScheduledAfterRunDontRun() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let callbackRan = ManagedAtomic(false)
|
let callbackRan = ManagedAtomic(false)
|
||||||
|
@ -148,13 +131,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
XCTAssertFalse(callbackRan.load(ordering: .relaxed))
|
XCTAssertFalse(callbackRan.load(ordering: .relaxed))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testSubmitRunsImmediately() throws {
|
func testSubmitRunsImmediately() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let callbackRan = ManagedAtomic(false)
|
let callbackRan = ManagedAtomic(false)
|
||||||
|
@ -173,13 +152,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
XCTAssertFalse(callbackRan.load(ordering: .relaxed))
|
XCTAssertFalse(callbackRan.load(ordering: .relaxed))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testSyncShutdownGracefullyRunsTasks() throws {
|
func testSyncShutdownGracefullyRunsTasks() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let callbackRan = ManagedAtomic(false)
|
let callbackRan = ManagedAtomic(false)
|
||||||
|
@ -194,13 +169,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
XCTAssertTrue(callbackRan.load(ordering: .relaxed))
|
XCTAssertTrue(callbackRan.load(ordering: .relaxed))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testShutdownGracefullyRunsTasks() throws {
|
func testShutdownGracefullyRunsTasks() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let callbackRan = ManagedAtomic(false)
|
let callbackRan = ManagedAtomic(false)
|
||||||
|
@ -215,13 +186,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
XCTAssertTrue(callbackRan.load(ordering: .relaxed))
|
XCTAssertTrue(callbackRan.load(ordering: .relaxed))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCanControlTime() throws {
|
func testCanControlTime() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let callbackCount = ManagedAtomic(0)
|
let callbackCount = ManagedAtomic(0)
|
||||||
|
@ -250,13 +217,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
XCTAssertEqual(callbackCount.load(ordering: .relaxed), 1)
|
XCTAssertEqual(callbackCount.load(ordering: .relaxed), 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCanScheduleMultipleTasks() throws {
|
func testCanScheduleMultipleTasks() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let sentinel = ManagedAtomic(0)
|
let sentinel = ManagedAtomic(0)
|
||||||
|
@ -277,13 +240,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testExecutedTasksFromScheduledOnesAreRun() throws {
|
func testExecutedTasksFromScheduledOnesAreRun() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let sentinel = ManagedAtomic(0)
|
let sentinel = ManagedAtomic(0)
|
||||||
|
@ -304,13 +263,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
XCTAssertEqual(sentinel.load(ordering: .relaxed), 2)
|
XCTAssertEqual(sentinel.load(ordering: .relaxed), 2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testScheduledTasksFromScheduledTasksProperlySchedule() throws {
|
func testScheduledTasksFromScheduledTasksProperlySchedule() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let sentinel = ManagedAtomic(0)
|
let sentinel = ManagedAtomic(0)
|
||||||
|
@ -350,13 +305,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
XCTAssertEqual(sentinel.load(ordering: .relaxed), 3)
|
XCTAssertEqual(sentinel.load(ordering: .relaxed), 3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testScheduledTasksFromExecutedTasks() throws {
|
func testScheduledTasksFromExecutedTasks() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let sentinel = ManagedAtomic(0)
|
let sentinel = ManagedAtomic(0)
|
||||||
|
@ -375,13 +326,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
XCTAssertEqual(sentinel.load(ordering: .relaxed), 2)
|
XCTAssertEqual(sentinel.load(ordering: .relaxed), 2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCancellingScheduledTasks() throws {
|
func testCancellingScheduledTasks() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let loop = NIOAsyncTestingEventLoop()
|
let loop = NIOAsyncTestingEventLoop()
|
||||||
|
@ -392,13 +339,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
|
|
||||||
await loop.advanceTime(by: .nanoseconds(20))
|
await loop.advanceTime(by: .nanoseconds(20))
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testScheduledTasksFuturesFire() throws {
|
func testScheduledTasksFuturesFire() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let fired = ManagedAtomic(false)
|
let fired = ManagedAtomic(false)
|
||||||
|
@ -411,13 +354,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
await loop.advanceTime(by: .nanoseconds(1))
|
await loop.advanceTime(by: .nanoseconds(1))
|
||||||
XCTAssertTrue(fired.load(ordering: .relaxed))
|
XCTAssertTrue(fired.load(ordering: .relaxed))
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testScheduledTasksFuturesError() throws {
|
func testScheduledTasksFuturesError() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let err = EmbeddedTestError()
|
let err = EmbeddedTestError()
|
||||||
|
@ -439,13 +378,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
await loop.advanceTime(by: .nanoseconds(1))
|
await loop.advanceTime(by: .nanoseconds(1))
|
||||||
XCTAssertTrue(fired.load(ordering: .relaxed))
|
XCTAssertTrue(fired.load(ordering: .relaxed))
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testTaskOrdering() throws {
|
func testTaskOrdering() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
// This test validates that the ordering of task firing on NIOAsyncTestingEventLoop via
|
// This test validates that the ordering of task firing on NIOAsyncTestingEventLoop via
|
||||||
|
@ -526,13 +461,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
// Now the final value should be 6.
|
// Now the final value should be 6.
|
||||||
XCTAssertEqual(orderingCounter.load(ordering: .relaxed), 6)
|
XCTAssertEqual(orderingCounter.load(ordering: .relaxed), 6)
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCancelledScheduledTasksDoNotHoldOnToRunClosure() throws {
|
func testCancelledScheduledTasksDoNotHoldOnToRunClosure() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let eventLoop = NIOAsyncTestingEventLoop()
|
let eventLoop = NIOAsyncTestingEventLoop()
|
||||||
|
@ -559,13 +490,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
XCTAssertEqual(EventLoopError.cancelled, error as? EventLoopError)
|
XCTAssertEqual(EventLoopError.cancelled, error as? EventLoopError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testDrainScheduledTasks() throws {
|
func testDrainScheduledTasks() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let eventLoop = NIOAsyncTestingEventLoop()
|
let eventLoop = NIOAsyncTestingEventLoop()
|
||||||
|
@ -585,13 +512,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
await eventLoop.shutdownGracefully()
|
await eventLoop.shutdownGracefully()
|
||||||
XCTAssertEqual(tasksRun.load(ordering: .relaxed), 2)
|
XCTAssertEqual(tasksRun.load(ordering: .relaxed), 2)
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testDrainScheduledTasksDoesNotRunNewlyScheduledTasks() throws {
|
func testDrainScheduledTasksDoesNotRunNewlyScheduledTasks() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let eventLoop = NIOAsyncTestingEventLoop()
|
let eventLoop = NIOAsyncTestingEventLoop()
|
||||||
|
@ -608,13 +531,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
await eventLoop.shutdownGracefully()
|
await eventLoop.shutdownGracefully()
|
||||||
XCTAssertEqual(tasksRun.load(ordering: .relaxed), 1)
|
XCTAssertEqual(tasksRun.load(ordering: .relaxed), 1)
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAdvanceTimeToDeadline() throws {
|
func testAdvanceTimeToDeadline() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let eventLoop = NIOAsyncTestingEventLoop()
|
let eventLoop = NIOAsyncTestingEventLoop()
|
||||||
|
@ -628,13 +547,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
await eventLoop.advanceTime(to: deadline)
|
await eventLoop.advanceTime(to: deadline)
|
||||||
XCTAssertEqual(tasksRun.load(ordering: .relaxed), 1)
|
XCTAssertEqual(tasksRun.load(ordering: .relaxed), 1)
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testWeCantTimeTravelByAdvancingTimeToThePast() throws {
|
func testWeCantTimeTravelByAdvancingTimeToThePast() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let eventLoop = NIOAsyncTestingEventLoop()
|
let eventLoop = NIOAsyncTestingEventLoop()
|
||||||
|
@ -656,13 +571,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
await eventLoop.advanceTime(by: .seconds(2))
|
await eventLoop.advanceTime(by: .seconds(2))
|
||||||
XCTAssertEqual(tasksRun.load(ordering: .relaxed), 1)
|
XCTAssertEqual(tasksRun.load(ordering: .relaxed), 1)
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testExecuteInOrder() throws {
|
func testExecuteInOrder() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let eventLoop = NIOAsyncTestingEventLoop()
|
let eventLoop = NIOAsyncTestingEventLoop()
|
||||||
|
@ -686,13 +597,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
await eventLoop.run()
|
await eventLoop.run()
|
||||||
XCTAssertEqual(counter.load(ordering: .relaxed), 3)
|
XCTAssertEqual(counter.load(ordering: .relaxed), 3)
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testScheduledTasksInOrder() throws {
|
func testScheduledTasksInOrder() throws {
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { throw XCTSkip() }
|
||||||
XCTAsyncTest {
|
XCTAsyncTest {
|
||||||
let eventLoop = NIOAsyncTestingEventLoop()
|
let eventLoop = NIOAsyncTestingEventLoop()
|
||||||
|
@ -716,8 +623,5 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
|
||||||
await eventLoop.advanceTime(by: .seconds(1))
|
await eventLoop.advanceTime(by: .seconds(1))
|
||||||
XCTAssertEqual(counter.load(ordering: .relaxed), 3)
|
XCTAssertEqual(counter.load(ordering: .relaxed), 3)
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
throw XCTSkip()
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#if compiler(>=5.5.2) && canImport(_Concurrency)
|
|
||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
extension XCTestCase {
|
extension XCTestCase {
|
||||||
|
@ -102,5 +102,3 @@ internal func XCTAssertNoThrowWithResult<Result>(
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -26,9 +26,7 @@ struct UnsafeTransfer<Wrapped> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension UnsafeTransfer: @unchecked Sendable {}
|
extension UnsafeTransfer: @unchecked Sendable {}
|
||||||
#endif
|
|
||||||
|
|
||||||
extension UnsafeTransfer: Equatable where Wrapped: Equatable {}
|
extension UnsafeTransfer: Equatable where Wrapped: Equatable {}
|
||||||
extension UnsafeTransfer: Hashable where Wrapped: Hashable {}
|
extension UnsafeTransfer: Hashable where Wrapped: Hashable {}
|
||||||
|
@ -46,6 +44,5 @@ final class UnsafeMutableTransferBox<Wrapped> {
|
||||||
self.wrappedValue = wrappedValue
|
self.wrappedValue = wrappedValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if swift(>=5.5) && canImport(_Concurrency)
|
|
||||||
extension UnsafeMutableTransferBox: @unchecked Sendable {}
|
extension UnsafeMutableTransferBox: @unchecked Sendable {}
|
||||||
#endif
|
|
||||||
|
|
Loading…
Reference in New Issue