 
       repeat {
         waiter.pointee.next = waiterQueue(from: state)
-        let newState = Int(bitPattern: waiter) | state.state
+        let newState = Int(waiter, tag: state.tag)
         // read-modify-write `deferredState` with memory_order_release.
         // this means that this write is in the release sequence of all previous writes.
         // a subsequent read-from `deferredState` will therefore synchronize-with all previous writes.


      repeat {
        waiter.pointee.next = waiterQueue(from: state)
        let newState = Int(bitPattern: waiter) | state.state
        // read-modify-write `deferredState` with memory_order_release.
        // this means that this write is in the release sequence of all previous writes.
        // a subsequent read-from `deferredState` will therefore synchronize-with all previous writes.

  static let resolved =  0x3
  private static let stateMask = 0x3

  init(_ pointer: UnsafeMutableRawPointer, tag: Int)
  {
    self = Int(bitPattern: pointer) | (tag & .stateMask)
  }

  var isResolved: Bool { return tag == .resolved }

  var tag: Int { return self & .stateMask }
  var ptr: UnsafeMutableRawPointer? { return UnsafeMutableRawPointer(bitPattern: self & ~.stateMask) }
}

/// An asynchronous computation.
