code: private Listener clearListeners(Listener onto) {
      // We need to
      // 1. atomically swap the listeners with TOMBSTONE, this is because addListener uses that to
      //    to synchronize with us
      // 2. reverse the linked list, because despite our rather clear contract, people depend on us
      //    executing listeners in the order they were added
      // 3. push all the items onto 'onto' and return the new head of the stack
      Listener head;
      do {
        head = listeners;
      } while (!ATOMIC_HELPER.casListeners(this, head, Listener.TOMBSTONE));
      Listener reversedList = onto;
      while (head != null) {
        Listener tmp = head;
        head = head.next;
        tmp.next = reversedList;
        reversedList = tmp;
      }
      return reversedList;
    }
docs: Clears the {@link #listeners} list and prepends its contents to {@code onto}, least recently
  added first.