From ff3e9bcdd1109aae1839de00cac72e467d82752c Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 13 Sep 2018 15:15:08 -0500 Subject: [PATCH] cr: add comment about operation queue --- SignalServiceKit/src/Account/TSPreKeyManager.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SignalServiceKit/src/Account/TSPreKeyManager.m b/SignalServiceKit/src/Account/TSPreKeyManager.m index 43005acdd..b3f9d5fee 100644 --- a/SignalServiceKit/src/Account/TSPreKeyManager.m +++ b/SignalServiceKit/src/Account/TSPreKeyManager.m @@ -81,6 +81,12 @@ static const NSUInteger kMaxPrekeyUpdateFailureCount = 5; { static dispatch_once_t onceToken; static NSOperationQueue *operationQueue; + + // PreKey state lives in two places - on the client and on the service. + // Some of our pre-key operations depend on the service state, e.g. we need to check our one-time-prekey count + // before we decide to upload new ones. This potentially entails multiple async operations, all of which should + // complete before starting any other pre-key operation. That's why a dispatch_queue is insufficient for + // coordinating PreKey operations and instead we use NSOperation's on a serial NSOperationQueue. dispatch_once(&onceToken, ^{ operationQueue = [NSOperationQueue new]; operationQueue.name = @"TSPreKeyManager";