Fix some deadlocks.

This commit is contained in:
Damiano Galassi committed 2018-03-23 12:43:29 +01:00
1 parent bc3d17c9f9
commit 3e332fbde5
2 files changed
+8 -11

No files matched your search

-2
View File
@@ -15,8 +15,6 @@ typedef NS_ENUM(NSUInteger, SBQueueStatus) {
SBQueueStatusUnknown = 0,
SBQueueStatusWorking,
SBQueueStatusCompleted,
SBQueueStatusFailed,
SBQueueStatusCancelled,
};
extern NSString *SBQueueWorkingNotification;
+8 -9
View File
@@ -222,14 +222,15 @@ NSString *SBQueueCancelledNotification = @"SBQueueCancelledNotification";
* Starts the queue.
*/
- (void)start {
if (self.status == SBQueueStatusWorking || self.cancelled) {
return;
} else {
self.status = SBQueueStatusWorking;
}
dispatch_sync(self.arrayQueue, ^{
if (self.status == SBQueueStatusWorking || self.cancelled) {
return;
} else {
self.status = SBQueueStatusWorking;
}
});
dispatch_async(self.workQueue, ^{
// Enable sleep assertion
[self disableSleep];
@@ -287,7 +288,7 @@ NSString *SBQueueCancelledNotification = @"SBQueueCancelledNotification";
[self handleSBStatusWorking:100 index:self.currentIndex];
}
if (self.status == SBQueueStatusCancelled) {
if (self.cancelled) {
break;
}
}
@@ -344,7 +345,6 @@ NSString *SBQueueCancelledNotification = @"SBQueueCancelledNotification";
* sends SBQueueFailedNotification.
*/
- (void)handleSBStatusFailed:(NSError *)error {
self.status = SBQueueStatusFailed;
[[NSNotificationCenter defaultCenter] postNotificationName:SBQueueFailedNotification object:self userInfo:@{@"Error" : error != nil ? error : [NSNull null]}];
}
@@ -353,7 +353,6 @@ NSString *SBQueueCancelledNotification = @"SBQueueCancelledNotification";
* sends SBQueueCancelledNotification.
*/
- (void)handleSBStatusCancelled {
self.status = SBQueueStatusCancelled;
[[NSNotificationCenter defaultCenter] postNotificationName:SBQueueCancelledNotification object:self];
}