     
     /// Run `block` after `self` is completed with specific queue.
     public func complete<R>(queue: dispatch_queue_t, _ block: (Result) -> R) -> SDTask<R> {
-        let task = SDTask<R>(group, queue)
-        dispatch_group_notify(group, queue) {
-            defer { task.signal() }
-            task._result = block(self.result)
-        }
-        return task
-    }
-}
+        return _lck.synchronized {
+            if completed {
+                return SDTask<R>(queue) { block(self.result) }
+            }
+            let task = SDTask<R>(group, queue)
+            _notify.append {
+                dispatch_group_async(self.group, queue) {
+                    defer { task.signal() }
+                    task._result = block(self.result)
+                }
+            }
+            return task
+        }
+    }
+}

        dispatch_group_async(group, queue) {
            defer { self.signal() }
            self._result = block()
        }
    }
    

    private let group: dispatch_group_t
    private let queue: dispatch_queue_t
    
    private typealias NotifyType = () -> ()
    private var _lck: SDSpinLock = SDSpinLock()
    private var _notify: [NotifyType] = []
    
    private var _result: Result! = nil
    
    private init(_ group: dispatch_group_t, _ queue: dispatch_queue_t) {
        self.group = group
        self.queue = queue
        dispatch_group_notify(group, queue) {
            self._lck.synchronized {
                self._notify.forEach { $0() }
                self._notify = []
            }
        }
    }
    
    /// Create a SDTask and compute block with specific queue.
