             }
         }
     }
+    
+    func addOpToSet(op: NSOperation) {
+        dispatch_async(opsQueue) {
+            self.ops.insert(op)
+        }
+    }
+    
+    func removeOpFromSet(op: NSOperation) {
+        dispatch_async(opsQueue) {
+            self.ops.remove(op)
+        }
+    }
 }

    - Setting up dependencies to enforce mutual exclusivity
*/
public class OperationQueue: NSOperationQueue {
    private var ops: Set<NSOperation> = Set()
    public weak var delegate: OperationQueueDelegate?
    
    override public  func addOperation(operation: NSOperation) {
        ops.insert(operation)
        if let op = operation as? Operation {
            
            // Set up a `BlockObserver` to invoke the `OperationQueueDelegate` method.

                finishHandler: { [weak self] in
                    if let q = self {
                        q.delegate?.operationQueue?(q, operationDidFinish: $0, withErrors: $1)
                        q.removeOpFromSet($0)
                    }
                }
            )
