Skip to content

Commit b6fb855

Browse files
committed
fix(ios): use synchronous barrier writes in ThreadSafeDictionary
Async barrier writes in the subscript setter and removeAll() created a window where values were enqueued but not yet committed, causing callbacks to be nil on fast reconnects.
1 parent 61365c6 commit b6fb855

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ios/Sources/BluetoothLe/ThreadSafeDictionary.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ThreadSafeDictionary<K: Hashable, T> {
99
return queue.sync { dictionary[key] }
1010
}
1111
set {
12-
queue.async(flags: .barrier) { self.dictionary[key] = newValue }
12+
queue.sync(flags: .barrier) { self.dictionary[key] = newValue }
1313
}
1414
}
1515

@@ -24,7 +24,7 @@ class ThreadSafeDictionary<K: Hashable, T> {
2424
}
2525

2626
func removeAll() {
27-
queue.async(flags: .barrier) {
27+
queue.sync(flags: .barrier) {
2828
self.dictionary.removeAll()
2929
}
3030
}

0 commit comments

Comments
 (0)