Move more work off the main thread.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 9573e0e16d
commit facbc56062

@ -178,9 +178,7 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
object:nil]; object:nil];
// Try to start processing. // Try to start processing.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self scheduleProcessing]; [self scheduleProcessing];
});
return self; return self;
} }
@ -198,10 +196,12 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
// Schedules a processing pass, unless one is already scheduled. // Schedules a processing pass, unless one is already scheduled.
- (void)scheduleProcessing - (void)scheduleProcessing
{ {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
@synchronized(self) @synchronized(self)
{ {
if ([TSDatabaseView hasPendingViewRegistrations]) { if ([TSDatabaseView hasPendingViewRegistrations]) {
DDLogInfo(@"%@ Deferring read receipt processing due to pending database view registrations.", self.tag); DDLogInfo(
@"%@ Deferring read receipt processing due to pending database view registrations.", self.tag);
return; return;
} }
if (self.isProcessing) { if (self.isProcessing) {
@ -222,6 +222,7 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
[self process]; [self process];
}); });
} }
});
} }
- (void)process - (void)process

Loading…
Cancel
Save