Skip to content

Commit f36a793

Browse files
authored
Merge pull request #189 from swift-server-community/fix-warnings
Fix EventLoop warnings
2 parents 15dbd83 + f67efbf commit f36a793

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let package = Package(
1818
],
1919
dependencies: [
2020
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
21-
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0"..<"3.0.0"),
21+
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0"..<"4.0.0"),
2222
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.10.0"),
2323
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
2424
.package(url: "https://github.com/apple/swift-nio.git", from: "2.42.0"),

Sources/APNS/APNSClient.swift

+8-9
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import NIOCore
2222
import NIOHTTP1
2323
import NIOSSL
2424
import NIOTLS
25+
import NIOPosix
2526

2627
/// A client to talk with the Apple Push Notification services.
2728
public final class APNSClient<Decoder: APNSJSONDecoder, Encoder: APNSJSONEncoder>: APNSClientProtocol {
@@ -100,19 +101,17 @@ public final class APNSClient<Decoder: APNSJSONDecoder, Encoder: APNSJSONEncoder
100101
httpClientConfiguration.httpVersion = .automatic
101102
httpClientConfiguration.proxy = configuration.proxy
102103

103-
let httpClientEventLoopGroupProvider: HTTPClient.EventLoopGroupProvider
104-
105104
switch eventLoopGroupProvider {
106105
case .shared(let eventLoopGroup):
107-
httpClientEventLoopGroupProvider = .shared(eventLoopGroup)
106+
self.httpClient = HTTPClient(
107+
eventLoopGroupProvider: .shared(eventLoopGroup),
108+
configuration: httpClientConfiguration
109+
)
108110
case .createNew:
109-
httpClientEventLoopGroupProvider = .createNew
111+
self.httpClient = HTTPClient(
112+
configuration: httpClientConfiguration
113+
)
110114
}
111-
112-
self.httpClient = HTTPClient(
113-
eventLoopGroupProvider: httpClientEventLoopGroupProvider,
114-
configuration: httpClientConfiguration
115-
)
116115
}
117116

118117
/// Shuts down the client and event loop gracefully. This function is clearly an outlier in that it uses a completion

Tests/APNSTests/APNSAuthenticationTokenManagerTests.swift

+11-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
@testable import APNSCore
1616
import Crypto
1717
import XCTest
18+
import NIOConcurrencyHelpers
1819

1920
final class APNSAuthenticationTokenManagerTests: XCTestCase {
2021
private static let signingKey = """
@@ -129,11 +130,19 @@ final class TestClock<Duration: DurationProtocol & Hashable>: Clock {
129130
}
130131

131132
let minimumResolution: Duration = .zero
132-
var now: Instant
133+
private let _now: NIOLockedValueBox<Instant>
134+
135+
var now: Instant {
136+
get {
137+
self._now.withLockedValue { $0 }
138+
} set {
139+
self._now.withLockedValue { $0 = newValue }
140+
}
141+
}
133142

134143

135144
public init(now: Instant = .init()) {
136-
self.now = .init()
145+
self._now = .init(now)
137146
}
138147

139148
public func sleep(until deadline: Instant, tolerance: Duration? = nil) async throws {

0 commit comments

Comments
 (0)