mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 18:25:19 +00:00
Merge pull request #892 from permissionlesstech/fix/thread-sleep-bleservice
Replace Thread.sleep with cooperative RunLoop delay
This commit is contained in:
@@ -521,8 +521,11 @@ final class BLEService: NSObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Give leave message a moment to send
|
// Give leave message a moment to send (cooperative delay allows BLE callbacks to fire)
|
||||||
Thread.sleep(forTimeInterval: TransportConfig.bleThreadSleepWriteShortDelaySeconds)
|
let deadline = Date().addingTimeInterval(TransportConfig.bleThreadSleepWriteShortDelaySeconds)
|
||||||
|
while Date() < deadline {
|
||||||
|
RunLoop.current.run(until: Date().addingTimeInterval(0.01))
|
||||||
|
}
|
||||||
|
|
||||||
// Clear pending notifications
|
// Clear pending notifications
|
||||||
collectionsQueue.sync(flags: .barrier) {
|
collectionsQueue.sync(flags: .barrier) {
|
||||||
|
|||||||
Reference in New Issue
Block a user