Rework flush of registration connection(s).

pull/1/head
Matthew Chen 7 years ago
parent e1138df771
commit a264268253

@ -136,24 +136,16 @@ void runAsyncRegistrationsForStorage(OWSStorage *storage)
DDLogVerbose(@"%@ async registrations enqueued.", self.logTag); DDLogVerbose(@"%@ async registrations enqueued.", self.logTag);
// Flush the write queue to ensure all async registrations have begun. // Use an empty read/write transaction to to ensure all async registrations have completed.
[[self newDatabaseConnection] [[self newDatabaseConnection] asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
flushTransactionsWithCompletionQueue:dispatch_get_main_queue() // Do nothing.
completionBlock:^{
// Block until all async registrations are complete.
// //
// NOTE: This has to happen on the "registration connections" for this // We can't use flushTransactionsWithCompletionQueue because it
// database. // doesn't flush the YapDatabase.writeQueue.
OWSAssert(!self.areAsyncRegistrationsComplete);
[pendingRegistrationConnectionSet removeObject:dbConnection];
if (pendingRegistrationConnectionSet.count > 0) {
DDLogVerbose(@"%@ registration "
@"connection flushed.",
self.logTag);
return;
} }
completionQueue:dispatch_get_main_queue()
completionBlock:^{
OWSAssert(!self.areAsyncRegistrationsComplete);
DDLogVerbose(@"%@ async registrations complete.", self.logTag); DDLogVerbose(@"%@ async registrations complete.", self.logTag);

Loading…
Cancel
Save