   {
     let deferred = Deferred<U>()
     self.notify(queue) {
-      (result: T) -> Void in
+      value in
       deferred.setState(.Running)
-      deferred.value = task(result)
+      deferred.setValue(transform(value))
     }
     return deferred
   }

  {
    let deferred = Deferred<U>()
    self.notify(queue) {
      (result: T) -> Void in
      deferred.setState(.Running)
      task(result).notify(queue) { deferred.value = $0 }
    }
    return deferred
  }

    }
  }
  
  private func setValue(value: T, trapOnFailure: Bool = true)
  { // A very simple turnstile to ensure only one thread can succeed
    if setState(.Assigning)
    {
      v = value
      guard setState(.Completed) else { fatalError("Could not complete assignment of value in \(__FUNCTION__)") }
      // The result is now available for the world
    }
    else if trapOnFailure { fatalError("Probable attempt to set value of Deferred twice with \(__FUNCTION__)") }
  }

  // MARK: public interface
