     
     /// Result of task.
     public final var result: Result {
-        if !completed {
-            dispatch_semaphore_wait(self.sem, DISPATCH_TIME_FOREVER)
-            defer { dispatch_semaphore_signal(self.sem) }
-        }
+        dispatch_once(&token) { self.block(self) }
         return self._result!
     }
 }


public class SDTask<Result> : SDAtomic {
    
    private let sem: dispatch_semaphore_t = dispatch_semaphore_create(0)
    
    private var _notify: [(Result) -> Void] = []
    
    private var _lck: SDSpinLock = SDSpinLock()
    private var _result: Result?
    
    private init(queue: dispatch_queue_t, suspend: ((Result) -> Bool)?, block: () -> Result) {

                _self._notify = []
            } else {
                let result = block()
                dispatch_once(&_self.token) { _self._result = result }
                _self.signal()
            }
        }
