Skip to content

Commit 421db12

Browse files
authored
NIOLock (#123)
* typo * NIOLock * Update GH Actions
1 parent 936f11f commit 421db12

File tree

7 files changed

+17
-11
lines changed

7 files changed

+17
-11
lines changed

.github/workflows/api-breakage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
linux:
88
runs-on: ubuntu-latest
99
container:
10-
image: swift:5.6-focal
10+
image: swift:5.7
1111
steps:
1212
- name: Checkout
1313
uses: actions/checkout@v3

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ jobs:
4848
strategy:
4949
matrix:
5050
tag:
51-
- swift:5.3
5251
- swift:5.4
5352
- swift:5.5
5453
- swift:5.6
54+
- swift:5.7
5555
container:
5656
image: ${{ matrix.tag }}
5757
services:

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let package = Package(
1111
dependencies: [
1212
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.0.0"),
1313
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
14-
.package(url: "https://github.com/apple/swift-nio.git", from: "2.33.0"),
14+
.package(url: "https://github.com/apple/swift-nio.git", from: "2.42.0"),
1515
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.14.0"),
1616
.package(url: "https://github.com/apple/swift-nio-transport-services.git", from: "1.6.0"),
1717
],

Sources/MQTTNIO/MQTTClient.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ public final class MQTTClient {
8282
/// flag to tell is client is shutdown
8383
private let isShutdown = ManagedAtomic(false)
8484

85+
#if swift(>=5.6)
86+
typealias ShutdownCallback = @Sendable (Error?) -> Void
87+
#else
88+
typealias ShutdownCallback = (Error?) -> Void
89+
#endif
90+
8591
/// Create MQTT client
8692
/// - Parameters:
8793
/// - host: host name
@@ -160,7 +166,7 @@ public final class MQTTClient {
160166
Current eventLoop: \(eventLoop)
161167
""")
162168
}
163-
let errorStorageLock = Lock()
169+
let errorStorageLock = NIOLock()
164170
var errorStorage: Error?
165171
let continuation = DispatchWorkItem {}
166172
self.shutdown(queue: DispatchQueue(label: "mqtt-client.shutdown")) { error in
@@ -403,7 +409,7 @@ public final class MQTTClient {
403409
var closeListeners = MQTTListeners<Void>()
404410
var shutdownListeners = MQTTListeners<Void>()
405411
private var _connection: MQTTConnection?
406-
private var lock = Lock()
412+
private var lock = NIOLock()
407413
}
408414

409415
internal extension MQTTClient {

Sources/MQTTNIO/MQTTCoreTypes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public struct MQTTSuback: _MQTTSendable {
9999
case failure = 0x80
100100
}
101101

102-
/// MQTT v5 subscribute return codes
102+
/// MQTT v5 subscribe return codes
103103
public let returnCodes: [ReturnCode]
104104

105105
init(returnCodes: [MQTTSuback.ReturnCode]) {

Sources/MQTTNIO/MQTTInflight.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the MQTTNIO project
44
//
5-
// Copyright (c) 2020-2021 Adam Fowler
5+
// Copyright (c) 2020-2022 Adam Fowler
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -17,7 +17,7 @@ import NIOConcurrencyHelpers
1717
/// Array of inflight packets. Used to resend packets when reconnecting to server
1818
struct MQTTInflight {
1919
init() {
20-
self.lock = Lock()
20+
self.lock = NIOLock()
2121
self.packets = .init(initialCapacity: 4)
2222
}
2323

@@ -43,6 +43,6 @@ struct MQTTInflight {
4343
}
4444
}
4545

46-
private let lock: Lock
46+
private let lock: NIOLock
4747
private(set) var packets: CircularBuffer<MQTTPacket>
4848
}

Sources/MQTTNIO/MQTTListeners.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the MQTTNIO project
44
//
5-
// Copyright (c) 2020-2021 Adam Fowler
5+
// Copyright (c) 2020-2022 Adam Fowler
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -37,6 +37,6 @@ struct MQTTListeners<ReturnType> {
3737
}
3838
}
3939

40-
private let lock = Lock()
40+
private let lock = NIOLock()
4141
private var listeners: [String: Listener] = [:]
4242
}

0 commit comments

Comments
 (0)