private boolean clearLongDirty(final int idx) { if (!this.longDirty.weakCompareAndSet(idx, 1/* expected */, 0/* update */)) { return this.longDirty.compareAndSet(idx, 1/* expected */, 0/* update */); } return true; }
private boolean clearIntDirty(final int idx) { if (!this.intDirty.weakCompareAndSet(idx, 1/* expected */, 0/* update */)) { return this.intDirty.compareAndSet(idx, 1/* expected */, 0/* update */); } return true; }
private void setIntDirty(final int idx) { if (!this.intDirty.weakCompareAndSet(idx, 0/* expected */, 1/* update */)) { if (!isIntDirty(idx)) { this.intDirty.set(idx, 1); } } }
private void setLongDirty(final int idx) { if (!this.longDirty.weakCompareAndSet(idx, 0/* expected */, 1/* update */)) { if (!isLongDirty(idx)) { this.longDirty.set(idx, 1); } } }
private final boolean clearIntDirty(final int idx) { if (!this.intDirty.weakCompareAndSet(idx, 1/*expected*/, 0/*update*/)) { return this.intDirty.compareAndSet(idx, 1/*expected*/, 0/*update*/); } return true; } private final boolean clearLongDirty(final int idx) {
java.util.concurrent.atomic.AtomicIntegerArray aia; .... void remove(int i) { int j = i/32; //gets which array index to access do { int oldVal = aia.get(j); int newVal = oldVal & ~(1 << (i%32)); boolean updated = aia.weakCompareAndSet(j, oldVal, newVal); } while(!updated); }
private final boolean clearLongDirty(final int idx) { if (!this.longDirty.weakCompareAndSet(idx, 1/*expected*/, 0/*update*/)) { return this.longDirty.compareAndSet(idx, 1/*expected*/, 0/*update*/); } return true; } private final void setIntDirty(final int idx) {
private int localSeq(String name) { int hash = localHashIndex(name); int num = localSeqs.incrementAndGet(hash); if (num > 50000000) { localSeqs.weakCompareAndSet(hash, num, ThreadLocalRandom.current().nextInt(100)); } return num; }
private final void setLongDirty(final int idx) { if (!this.longDirty.weakCompareAndSet(idx, 0/*expected*/, 1/*update*/)) { if (!isLongDirty(idx)) { this.longDirty.set(idx, 1); } } }
private final void setIntDirty(final int idx) { if (!this.intDirty.weakCompareAndSet(idx, 0/*expected*/, 1/*update*/)) { if (!isIntDirty(idx)) { this.intDirty.set(idx, 1); } } } private final void setLongDirty(final int idx) {