     public class func globalRequest(handler: ((NSMutableURLRequest) -> Void)?) {
         DelegateManager.sharedInstance.requestHandler = handler
     }
+}
+
+// Simple operator functions to simplify the assertions used above.
+private func <(lhs: HTTP.State, rhs: HTTP.State) -> Bool {
+	return lhs.rawValue < rhs.rawValue
+}
+
+private func ==(lhs: HTTP.State, rhs: HTTP.State) -> Bool {
+	return lhs.rawValue == rhs.rawValue
+}
+
+// Lock for getting / setting state safely
+extension NSLock {
+	func withCriticalScope<T>(@noescape block: Void -> T) -> T {
+		lock()
+		let value = block()
+		unlock()
+		return value
+	}
 }
 
 /**

        super.init()
        task = session.dataTaskWithRequest(req)
        DelegateManager.sharedInstance.addResponseForTask(task)
    }
    
    //MARK: Subclassed NSOperation Methods

    override public var asynchronous: Bool {
        return true
    }
	
	// If the operation has been cancelled, "isReady" should return true
	override public var ready: Bool {
		switch state {
			
		case .Initialized:
			return cancelled
			
		case .Ready:
			return super.ready || cancelled
			
		default:
			return false
		}
	}
	
    /// Returns if the task is current running.
	override public var executing: Bool {
		return state == .Executing
	}
	
	override public var finished: Bool {
		return state == .Finished
	}
    
    /**
    start/sends the HTTP task with a completionHandler. Use this when *NOT* using an NSOperationQueue.
