       }
 
       if r != nil
-      {
+      { // another thread succeeded ahead of this one
+        assert(r != p)
         p.deinitialize(count: 1)
         p.deallocate(capacity: 1)
         return false

  }

  /// Set the `Result` of this `Deferred`, change its state to `DeferredState.determined`,
  /// enqueue all notifications on the dispatch_queue, then return `true`.
  /// Note that a `Deferred` can only be determined once. On subsequent calls, `determine` will fail and return `false`.
  /// This operation is lock-free and thread-safe.
  ///

  fileprivate func determine(_ result: Result<Value>) -> Bool
  {
    if !CAS(current: nil, new: nil, target: &r)
    { // this Deferred is already determined
      return false
    }

    let p = UnsafeMutablePointer<Result<Value>>.allocate(capacity: 1)
    p.initialize(to: result)

    // ensure that only one thread can succeed
    while true
    {
      if CAS(current: nil, new: p, target: &r)
