     return state.pointer?.assumingMemoryBound(to: Result<Value, Error>.self)
   }
 
+  /// Get a pointer to the first `Waiter` for an unresolved `Deferred`.
+  /// `state` must have been read with `.acquire` memory ordering in order
+  /// to safely see all the changes from the thread last enqueued a `Waiter`.
+
+  private func waiterQueue(from state: Int) -> UnsafeMutablePointer<Waiter<Value>>?
+  {
+    if state.isResolved { return nil }
+    return state.pointer?.assumingMemoryBound(to: Waiter<Value>.self)
+  }
+
   deinit
   {
     let state = CAtomicsLoad(deferredState, .acquire)

      waiter.initialize(to: Waiter(source: source))

      repeat {
        waiter.pointee.next = state.waiters?.assumingMemoryBound(to: Waiter<Value>.self)
        let newState = Int(bitPattern: waiter) | state.state
        if CAtomicsCompareAndExchange(deferredState, &state, newState, .weak, .release, .relaxed)
        { // waiter is now enqueued; it will be deallocated at a later time by notifyWaiters()

      resolved.deinitialize(count: 1)
      resolved.deallocate()
    }
    else if let waiters = waiterQueue(from: state)
    {
      deallocateWaiters(waiters)
    }
    deferredState.deallocate()
  }
