     }
     
     func markCompleted() {
-        self.condition.lock()
-        self.completed = true
-        self.condition.unlock()
-        
+        OSAtomicCompareAndSwap32(0, 1, &self.completed)
         self.condition.broadcast()
     }
     

    /// Test whether response is ready to use.
    /// This function *Never* block
    public func isReady() -> Bool {
        self.condition.lock()
        defer {
            self.condition.unlock()
        }
        return self.completed
    }
    
    /// Suspend the ongoing task.

    }
    
    private func waitForComplete() {
        if OSAtomicCompareAndSwap32(1, 1, &self.completed) {
            return
        }
        
        self.condition.lock()
        while !OSAtomicCompareAndSwap32(1, 1, &self.completed) {
            self.condition.wait()
        }
        self.condition.unlock()
