 
     let _lock = NSObject()
     var _completed: Bool = false
+    let _completeCondition: NSCondition = NSCondition()
     var _result: Any? = nil
     var _error: HNTaskError? = nil
     var _continuations: (() -> Void)[] = []

                self._error = error
            }
            
            // TODO: notify
            
            for callback in self._continuations {
                callback()
            }

        return task
    }
    
    func waitUntilCompleted() {
        let doWait = doInLock { () -> Bool in
            if (self.isCompleted()) {
                return false
            }
            self._completeCondition.lock()
            return true
        }
        if doWait {
            self._completeCondition.wait()
            self._completeCondition.unlock()
        }
    }
    
}

// suppose it is used in this way
