             }
         }
     }
-    
-    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 let opsQueue = dispatch_queue_create("com.psoperations", DISPATCH_QUEUE_SERIAL)
    private var ops: Set<NSOperation> = Set()
    
    public weak var delegate: OperationQueueDelegate?
    
    override public  func addOperation(operation: NSOperation) {
        addOpToSet(operation)
        if let op = operation as? Operation {
            
            // Set up a `BlockObserver` to invoke the `OperationQueueDelegate` method.

            operation.addCompletionBlock { [weak self, weak operation] in
                guard let queue = self, let operation = operation else { return }
                queue.delegate?.operationQueue?(queue, operationDidFinish: operation, withErrors: [])
                operation.dependencies.forEach { operation.removeDependency($0) }
            }
        }
        
