Skip to content

Commit 2cfece4

Browse files
author
Daniel Browne
committed
Optimise 'decryptionKey' thread safe access to allow concurrent reads
1 parent 28c0190 commit 2cfece4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/Models/PusherChannel.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ open class PusherChannel: NSObject {
4747
public var auth: PusherAuth?
4848

4949
// Wrap accesses to the decryption key in a serial queue because it will be accessed from multiple threads
50-
@nonobjc private var decryptionKeyQueue = DispatchQueue(label: "com.pusher.pusherswift-channel-decryption-key-\(UUID().uuidString)")
50+
@nonobjc private var decryptionKeyQueue = DispatchQueue(label: "com.pusher.pusherswift-channel-decryption-key-\(UUID().uuidString)",
51+
attributes: .concurrent)
5152
@nonobjc private var decryptionKeyInternal: String?
5253
@nonobjc internal var decryptionKey: String? {
5354
get {
5455
return decryptionKeyQueue.sync { decryptionKeyInternal }
5556
}
56-
5757
set {
58-
decryptionKeyQueue.sync { decryptionKeyInternal = newValue }
58+
decryptionKeyQueue.async(flags: .barrier) { self.decryptionKeyInternal = newValue }
5959
}
6060
}
6161

0 commit comments

Comments
 (0)