From eed328e43f706fa9e4b2cc38e7ed1ba83dbb1c8c Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Mon, 22 Jul 2019 17:15:56 +0800 Subject: [PATCH 1/2] Fixes coalesce operation race condition --- Source/PINOperationQueue.m | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Source/PINOperationQueue.m b/Source/PINOperationQueue.m index d2a024e..5d0a38f 100644 --- a/Source/PINOperationQueue.m +++ b/Source/PINOperationQueue.m @@ -305,16 +305,10 @@ - (void)setMaxConcurrentOperations:(NSUInteger)maxConcurrentOperations - (BOOL)locked_cancelOperation:(id )operationReference { - BOOL success = NO; PINOperation *operation = [_referenceToOperations objectForKey:operationReference]; - if (operation) { - NSMutableOrderedSet *queue = [self operationQueueWithPriority:operation.priority]; - if ([queue containsObject:operation]) { - success = YES; - [queue removeObject:operation]; - [_queuedOperations removeObject:operation]; - dispatch_group_leave(_group); - } + BOOL success = [self locked_removeOperation:operation]; + if (success) { + dispatch_group_leave(_group); } return success; } @@ -448,13 +442,20 @@ - (void)waitUntilAllOperationsAreFinished } //Call with lock held -- (void)locked_removeOperation:(PINOperation *)operation +- (BOOL)locked_removeOperation:(PINOperation *)operation { if (operation) { NSMutableOrderedSet *priorityQueue = [self operationQueueWithPriority:operation.priority]; - [priorityQueue removeObject:operation]; - [_queuedOperations removeObject:operation]; + if ([priorityQueue containsObject:operation]) { + [priorityQueue removeObject:operation]; + [_queuedOperations removeObject:operation]; + if (operation.identifier) { + [_identifierToOperations removeObjectForKey:operation.identifier]; + } + return YES; + } } + return NO; } - (void)lock From a5682aa2bd4960d7fcbd3d5a482ebf425478750b Mon Sep 17 00:00:00 2001 From: Rahul Malik Date: Fri, 6 Sep 2019 10:06:28 -0700 Subject: [PATCH 2/2] Github CI (#26) * Add basic github ci configuration * Only build master / release branches on push --- .github/workflows/ci.yml | 15 +++++++++++++++ .github/workflows/ci_push.yml | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/ci_push.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6521cfe --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,15 @@ +name: Main workflow + +on: [pull_request] + +jobs: + Lint: + name: Run Unit and Integration Tests (macOS) + runs-on: macOS-latest + steps: + - name: Checkout the Git repository + uses: actions/checkout@v1 + - name: Setup dependencies + run: sudo gem install cocoapods danger danger-slack xcpretty + - name: Run Tests + run: make all diff --git a/.github/workflows/ci_push.yml b/.github/workflows/ci_push.yml new file mode 100644 index 0000000..7b653de --- /dev/null +++ b/.github/workflows/ci_push.yml @@ -0,0 +1,21 @@ +name: Main workflow + +on: + push: + # Sequence of patterns matched against refs/heads + branches: + - master # Push events on master branch + - 'releases/*' # Push events to branches matching refs/heads/releases/* + + +jobs: + Lint: + name: Run Unit and Integration Tests (macOS) + runs-on: macOS-latest + steps: + - name: Checkout the Git repository + uses: actions/checkout@v1 + - name: Setup dependencies + run: sudo gem install cocoapods danger danger-slack xcpretty + - name: Run Tests + run: make all