move pollers to one working queue to avoid race condition
This commit is contained in:
parent
97bf861809
commit
7a677a1800
|
@ -61,10 +61,10 @@ public final class ClosedGroupPoller : NSObject {
|
|||
|
||||
// MARK: Private API
|
||||
private func setUpPolling(for groupPublicKey: String) {
|
||||
Threading.closedGroupPollerQueue.async {
|
||||
self.poll(groupPublicKey).done(on: Threading.closedGroupPollerQueue) { [weak self] _ in
|
||||
Threading.pollerQueue.async {
|
||||
self.poll(groupPublicKey).done(on: Threading.pollerQueue) { [weak self] _ in
|
||||
self?.pollRecursively(groupPublicKey)
|
||||
}.catch(on: Threading.closedGroupPollerQueue) { [weak self] error in
|
||||
}.catch(on: Threading.pollerQueue) { [weak self] error in
|
||||
// The error is logged in poll(_:)
|
||||
self?.pollRecursively(groupPublicKey)
|
||||
}
|
||||
|
@ -87,10 +87,10 @@ public final class ClosedGroupPoller : NSObject {
|
|||
SNLog("Next poll interval for closed group with public key: \(groupPublicKey) is \(nextPollInterval) s.")
|
||||
timers[groupPublicKey] = Timer.scheduledTimerOnMainThread(withTimeInterval: nextPollInterval, repeats: false) { [weak self] timer in
|
||||
timer.invalidate()
|
||||
Threading.closedGroupPollerQueue.async {
|
||||
self?.poll(groupPublicKey).done(on: Threading.closedGroupPollerQueue) { _ in
|
||||
Threading.pollerQueue.async {
|
||||
self?.poll(groupPublicKey).done(on: Threading.pollerQueue) { _ in
|
||||
self?.pollRecursively(groupPublicKey)
|
||||
}.catch(on: Threading.closedGroupPollerQueue) { error in
|
||||
}.catch(on: Threading.pollerQueue) { error in
|
||||
// The error is logged in poll(_:)
|
||||
self?.pollRecursively(groupPublicKey)
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public final class OpenGroupPollerV2 : NSObject {
|
|||
self.isPolling = true
|
||||
let (promise, seal) = Promise<Void>.pending()
|
||||
promise.retainUntilComplete()
|
||||
Threading.openGroupPollerQueue.async {
|
||||
Threading.pollerQueue.async {
|
||||
OpenGroupAPIV2.compactPoll(self.server).done(on: OpenGroupAPIV2.workQueue) { [weak self] bodies in
|
||||
guard let self = self else { return }
|
||||
self.isPolling = false
|
||||
|
|
|
@ -5,6 +5,4 @@ internal enum Threading {
|
|||
internal static let jobQueue = DispatchQueue(label: "SessionMessagingKit.jobQueue", qos: .userInitiated)
|
||||
|
||||
internal static let pollerQueue = DispatchQueue(label: "SessionMessagingKit.pollerQueue")
|
||||
internal static let closedGroupPollerQueue = DispatchQueue(label: "SessionMessagingKit.closedGroupPollerQueue")
|
||||
internal static let openGroupPollerQueue = DispatchQueue(label: "SessionMessagingKit.openGroup")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue