Mark the `SDAsyncBlockOperation` safe using the lock and correct override method
This commit is contained in:
parent
974c3ff4ad
commit
f51992cfd6
|
@ -35,7 +35,9 @@
|
|||
}
|
||||
|
||||
- (void)start {
|
||||
@synchronized (self) {
|
||||
if (self.isCancelled) {
|
||||
self.finished = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -46,24 +48,42 @@
|
|||
if (self.executionBlock) {
|
||||
self.executionBlock(self);
|
||||
} else {
|
||||
[self complete];
|
||||
self.executing = NO;
|
||||
self.finished = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cancel {
|
||||
@synchronized (self) {
|
||||
[super cancel];
|
||||
if (self.isExecuting) {
|
||||
[self complete];
|
||||
self.executing = NO;
|
||||
self.finished = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)complete {
|
||||
[self willChangeValueForKey:@"isExecuting"];
|
||||
[self willChangeValueForKey:@"isFinished"];
|
||||
@synchronized (self) {
|
||||
if (self.isExecuting) {
|
||||
self.executing = NO;
|
||||
self.finished = YES;
|
||||
[self didChangeValueForKey:@"isExecuting"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setFinished:(BOOL)finished {
|
||||
[self willChangeValueForKey:@"isFinished"];
|
||||
_finished = finished;
|
||||
[self didChangeValueForKey:@"isFinished"];
|
||||
}
|
||||
|
||||
- (void)setExecuting:(BOOL)executing {
|
||||
[self willChangeValueForKey:@"isExecuting"];
|
||||
_executing = executing;
|
||||
[self didChangeValueForKey:@"isExecuting"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue