From af57cf3b90dc00b2e92277b996787efda54b6585 Mon Sep 17 00:00:00 2001 From: Peter Livesey Date: Wed, 14 Sep 2016 13:57:35 -0700 Subject: [PATCH] Checking if a block has been cancelled immediately before it runs (#35) --- ConsistencyManager/ConsistencyManager.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ConsistencyManager/ConsistencyManager.swift b/ConsistencyManager/ConsistencyManager.swift index 66b5b11..337dd0a 100644 --- a/ConsistencyManager/ConsistencyManager.swift +++ b/ConsistencyManager/ConsistencyManager.swift @@ -755,6 +755,10 @@ public class ConsistencyManager { // Default to true if weakOperation is nil return weakOperation?.cancelled ?? true } + // Let's check here to see if it's cancelled before we start + if cancelled() { + return + } task(cancelled) } weakOperation = operation