diff --git a/Package.swift b/Package.swift index c97be4eb..12fc4f34 100644 --- a/Package.swift +++ b/Package.swift @@ -18,7 +18,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"), - .package(url: "https://github.com/apple/swift-crypto.git", "1.0.0"..<"3.0.0"), + .package(url: "https://github.com/apple/swift-crypto.git", "1.0.0"..<"4.0.0"), .package(url: "https://github.com/swift-server/async-http-client.git", from: "1.10.0"), .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"), .package(url: "https://github.com/apple/swift-nio.git", from: "2.42.0"), diff --git a/Sources/APNS/APNSClient.swift b/Sources/APNS/APNSClient.swift index 50f4e4f0..e6beebeb 100644 --- a/Sources/APNS/APNSClient.swift +++ b/Sources/APNS/APNSClient.swift @@ -22,6 +22,7 @@ import NIOCore import NIOHTTP1 import NIOSSL import NIOTLS +import NIOPosix /// A client to talk with the Apple Push Notification services. public final class APNSClient: APNSClientProtocol { @@ -100,19 +101,17 @@ public final class APNSClient: Clock { } let minimumResolution: Duration = .zero - var now: Instant + private let _now: NIOLockedValueBox + + var now: Instant { + get { + self._now.withLockedValue { $0 } + } set { + self._now.withLockedValue { $0 = newValue } + } + } public init(now: Instant = .init()) { - self.now = .init() + self._now = .init(now) } public func sleep(until deadline: Instant, tolerance: Duration? = nil) async throws {