mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 01:45:20 +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
|
||||
Thread.sleep(forTimeInterval: TransportConfig.bleThreadSleepWriteShortDelaySeconds)
|
||||
// Give leave message a moment to send (cooperative delay allows BLE callbacks to fire)
|
||||
let deadline = Date().addingTimeInterval(TransportConfig.bleThreadSleepWriteShortDelaySeconds)
|
||||
while Date() < deadline {
|
||||
RunLoop.current.run(until: Date().addingTimeInterval(0.01))
|
||||
}
|
||||
|
||||
// Clear pending notifications
|
||||
collectionsQueue.sync(flags: .barrier) {
|
||||
|
||||
Reference in New Issue
Block a user