From bdd24e28f10d6581fd5f98ca321bff1354f512f6 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Tue, 15 Aug 2023 15:14:15 +0100 Subject: [PATCH] preconcurrency linux --- Sources/GRPC/ConnectionManagerChannelProvider.swift | 2 +- Tests/GRPCTests/CapturingLogHandler.swift | 4 ++++ .../ConnectionPool/PoolManagerStateMachineTests.swift | 11 +++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Sources/GRPC/ConnectionManagerChannelProvider.swift b/Sources/GRPC/ConnectionManagerChannelProvider.swift index 17a220874..f3696e7f7 100644 --- a/Sources/GRPC/ConnectionManagerChannelProvider.swift +++ b/Sources/GRPC/ConnectionManagerChannelProvider.swift @@ -69,7 +69,7 @@ internal struct DefaultChannelProvider: ConnectionManagerChannelProvider, Sendab @usableFromInline internal var errorDelegate: Optional @usableFromInline - internal var debugChannelInitializer: Optional< @Sendable (Channel) -> EventLoopFuture < Void>> + internal var debugChannelInitializer: Optional<@Sendable (Channel) -> EventLoopFuture > @inlinable internal init( diff --git a/Tests/GRPCTests/CapturingLogHandler.swift b/Tests/GRPCTests/CapturingLogHandler.swift index 499d3330c..eee64afa3 100644 --- a/Tests/GRPCTests/CapturingLogHandler.swift +++ b/Tests/GRPCTests/CapturingLogHandler.swift @@ -13,7 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#if os(Linux) +@preconcurrency import struct Foundation.Date +#else import struct Foundation.Date +#endif import class Foundation.DateFormatter import Logging import NIOConcurrencyHelpers diff --git a/Tests/GRPCTests/ConnectionPool/PoolManagerStateMachineTests.swift b/Tests/GRPCTests/ConnectionPool/PoolManagerStateMachineTests.swift index 896440041..f1254c255 100644 --- a/Tests/GRPCTests/ConnectionPool/PoolManagerStateMachineTests.swift +++ b/Tests/GRPCTests/ConnectionPool/PoolManagerStateMachineTests.swift @@ -346,19 +346,22 @@ private final class EmbeddedEventLoopGroup: EventLoopGroup, Sendable { return EventLoopIterator(self.loops) } - internal func shutdownGracefully(queue: DispatchQueue, _ callback: @escaping (Error?) -> Void) { - var shutdownError: Error? + internal func shutdownGracefully( + queue: DispatchQueue, + _ callback: @escaping @Sendable (Error?) -> Void + ) { + let lockedError = NIOLockedValueBox(nil) for loop in self.loops { loop.shutdownGracefully(queue: queue) { error in if let error = error { - shutdownError = error + lockedError.withLockedValue { $0 = error } } } } queue.sync { - callback(shutdownError) + callback(lockedError.withLockedValue { $0 }) } } }