Fix some threading issues.
This commit is contained in:
1 parent
cd67331db2
commit
11028208b8
4 files changed
+128
-103
No files matched your search
+9
-7
@@ -222,22 +222,25 @@ NSString *SBQueueCancelledNotification = @"SBQueueCancelledNotification";
|
||||
* Starts the queue.
|
||||
*/
|
||||
- (void)start {
|
||||
if (self.status == SBQueueStatusWorking) {
|
||||
if (self.status == SBQueueStatusWorking || self.cancelled) {
|
||||
return;
|
||||
} else {
|
||||
self.status = SBQueueStatusWorking;
|
||||
}
|
||||
|
||||
// Enable sleep assertion
|
||||
[self disableSleep];
|
||||
|
||||
dispatch_async(self.workQueue, ^{
|
||||
|
||||
// Enable sleep assertion
|
||||
[self disableSleep];
|
||||
|
||||
NSUInteger completedCount = 0;
|
||||
NSUInteger failedCount = 0;
|
||||
|
||||
for (;;) {
|
||||
@autoreleasepool {
|
||||
// Save to disk
|
||||
[self saveQueueToDisk];
|
||||
|
||||
NSError *outError = nil;
|
||||
BOOL noErr = NO;
|
||||
|
||||
@@ -280,6 +283,8 @@ NSString *SBQueueCancelledNotification = @"SBQueueCancelledNotification";
|
||||
|
||||
self.currentItem.delegate = nil;
|
||||
self.currentItem = nil;
|
||||
|
||||
[self handleSBStatusWorking:100 index:self.currentIndex];
|
||||
}
|
||||
|
||||
if (self.status == SBQueueStatusCancelled) {
|
||||
@@ -287,9 +292,6 @@ NSString *SBQueueCancelledNotification = @"SBQueueCancelledNotification";
|
||||
}
|
||||
}
|
||||
|
||||
// Save to disk
|
||||
[self saveQueueToDisk];
|
||||
|
||||
// Disable sleep assertion
|
||||
[self enableSleep];
|
||||
[self handleSBStatusCompleted:completedCount failed:failedCount];
|
||||
|
||||
Reference in new issue
Block a user