private void addCount(long x, int check) {
    CounterCell[] as;
    long b, s;
    if ((as = counterCells) != null
        || !U.compareAndSwapLong(this, BASECOUNT, b = baseCount, s = b + x)) {
      CounterHashCode hc;
      CounterCell a;
      long v;
      int m;
      boolean uncontended = true;
      if ((hc = threadCounterHashCode.get()) == null || as == null || (m = as.length - 1) < 0
          || (a = as[m & hc.code]) == null
          || !(uncontended = U.compareAndSwapLong(a, CELLVALUE, v = a.value, v + x))) {
        fullAddCount(x, hc, uncontended);
        return;
      }
      if (check <= 1) {
        return;
      }
      s = sumCount();
    }
    if (check >= 0) {
      Node<V>[] tab, nt;
      int n, sc;
      while (s >= (long) (sc = sizeCtl) && (tab = table) != null
          && (n = tab.length) < MAXIMUM_CAPACITY) {
        int rs = resizeStamp(n);
        if (sc < 0) {
          if ((sc >>> RESIZE_STAMP_SHIFT) != rs || sc == rs + 1 || sc == rs + MAX_RESIZERS
              || (nt = nextTable) == null || transferIndex <= 0) {
            break;
          }
          if (U.compareAndSwapInt(this, SIZECTL, sc, sc + 1)) {
            transfer(tab, nt);
          }
        } else if (U.compareAndSwapInt(this, SIZECTL, sc, (rs << RESIZE_STAMP_SHIFT) + 2)) {
          transfer(tab, null);
        }
        s = sumCount();
      }
    }
  }
Adds to count, and if table is too small and not already resizing, initiates transfer. If
already resizing, helps perform transfer if work is available. Rechecks occupancy after a
transfer to see if another resize is already needed because resizings are lagging additions.

@param x the count to add
@param check if <0, don't check resize, if <= 1 only check if uncontended
geode-core/src/main/java/org/apache/geode/internal/concurrent/CompactConcurrentHashSet2.java