Skip to content

Commit

Permalink
Mark TWLBlockOperation as ready if it gets cancelled
Browse files Browse the repository at this point in the history
This matches default `NSOperation` behavior, since cancelled operations
skip their work. Allowing them to be marked as ready means they can get
flushed from the queue faster.
  • Loading branch information
lilyball committed Aug 19, 2020
1 parent 8037325 commit 5f77b44
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sources/Private/TWLBlockOperation.m
Expand Up @@ -27,7 +27,12 @@ - (instancetype)init {
}

- (BOOL)isReady {
return [super isReady] && atomic_load_explicit(&_markedReady, memory_order_relaxed);
return [super isReady]
&& (atomic_load_explicit(&_markedReady, memory_order_relaxed)
// If we're cancelled, ignore the atomic bool since we won't be doing work.
// This matches the default behavior of `[super isReady]` with respect to
// dependencies as well.
|| self.isCancelled);
}

- (void)markReady {
Expand Down

0 comments on commit 5f77b44

Please sign in to comment.