     /// Run `block` after `self` is completed with specific queue.
     public final func then<R>(queue: dispatch_queue_t, _ block: (Result) -> R) -> SDTask<R> {
         return _lck.synchronized {
-            if _result != nil {
-                return SDTask<R>(queue: queue) { block(self.result) }
-            }
-            let task = SDTask<R>(queue)
-            _notify.append { task.submit { block(self.result) } }
+            let task = SDTask<R>(queue: queue, suspend: { _ in false }) { block(self.result) }
+            if _result == nil {
+                _notify.append(task)
+            } else {
+                task.signal()
+            }
             return task
         }
     }

    /// Suspend if `result` satisfies `predicate` with specific queue.
    public final func suspend(queue: dispatch_queue_t, _ predicate: (Result) -> Bool) -> SDTask<Result> {
        return _lck.synchronized {
            let task = SDTask<Result>(queue)
            if _result != nil {
                dispatch_async(queue) { task.suspend_signal(self.result, predicate) }
            } else {
                _notify.append { task.suspend_signal(self.result, predicate) }
            }
            return task
        }


// MARK: SDTask

public class SDTask<Result> : SDAtomic {
    
    private let sem: dispatch_semaphore_t = dispatch_semaphore_create(0)
    
    private var _notify: [SDAtomic] = []
    
    private var _lck: SDSpinLock = SDSpinLock()
    private var _result: Result?
    
    private let _block: () -> Result
    private var _suspend: (Result) -> Bool
    
    /// Create a SDTask and compute block with specific queue.
    private init(queue: dispatch_queue_t, suspend: (Result) -> Bool, block: () -> Result) {
        self._block = block
        self._suspend = suspend
        super.init(queue: queue) { atomic in
            let _self = atomic as! SDTask<Result>
            _self._lck.synchronized(_self.action)
        }
    }
    
    /// Create a SDTask and compute block with specific queue.
    public init(queue: dispatch_queue_t, block: () -> Result) {
        self._block = block
        self._suspend = { _ in false }
        super.init(queue: queue) { atomic in
            let _self = atomic as! SDTask<Result>
            _self._lck.synchronized(_self.action)
        }
        self.signal()
    }
    
    /// Create a SDTask and compute block with default queue.
    public init(block: () -> Result) {
        self._block = block
        self._suspend = { _ in false }
        super.init { atomic in
            let _self = atomic as! SDTask<Result>
            _self._lck.synchronized(_self.action)
        }
        self.signal()
    }
}

extension SDTask {
    
    private func action() {
        if _result == nil {
            _result = _block()
            self.signal()
        } else {
            if !_suspend(_result!) {
                _notify.forEach { $0.signal() }
            }
            _notify = []
        }
    }
    
    /// Return `true` iff task is completed.
