 
 extension SDTask {
     
-    fileprivate func createWorker(block: @escaping () -> Result) -> DispatchWorkItem {
-        return DispatchWorkItem { [weak self] in
+    fileprivate func createWorker(qos: DispatchQoS, flags: DispatchWorkItemFlags, block: @escaping () -> Result) -> DispatchWorkItem {
+        return DispatchWorkItem(qos: qos, flags: flags) { [weak self] in
             let value = block()
             if let _self = self {
                 _self.storage.value = value

    
    /// Suspend if `result` satisfies `predicate` with specific queue.
    @discardableResult
    public func suspend(queue: DispatchQueue, where predicate: @escaping (Result) -> Bool) -> SDTask<Result> {
        let result = SDTask<Result>(queue: queue)
        let worker = result.createWorker { self.result }
        result.worker = worker
        self.worker.notify(queue: queue) {
            if !predicate(self.result) {
                worker.perform()
            }

    
    /// Run `block` after `self` is completed with specific queue.
    @discardableResult
    public func then<R>(queue: DispatchQueue, qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], block: @escaping (Result) -> R) -> SDTask<R> {
        let result = SDTask<R>(queue: queue)
        let worker = result.createWorker(qos: qos, flags: flags) { block(self.result) }
        result.worker = worker
        self.worker.notify(queue: queue, execute: worker)
        return result
