for (int i = 0; i < ts.intStore.length(); i++) { synchronized (this.intReadPrepLock[i]) { int delta = ts.intStore.getAndSet(i, 0); if (delta != 0) { this.intStorage.getAndAdd(i, delta);
private int doIntRead(final int idx) { // early out for sampler; it called prepareForSample if (samplerThread.get() != null) { return this.intStorage.get(idx); } synchronized (this.intReadPrepLock[idx]) { if (!isIntDirty(idx)) { // no need to prepare if not dirty return this.intStorage.get(idx); } } // this can take a while so release sync prepareThreadStoreList(); synchronized (this.intReadPrepLock[idx]) { if (!clearIntDirty(idx)) { // no need to prepare if not dirty return this.intStorage.get(idx); } int delta = 0; for (ThreadStorage ts : this.threadStoreList) { delta += ts.intStore.getAndSet(idx, 0); } if (delta != 0) { return this.intStorage.addAndGet(idx, delta); } else { return this.intStorage.get(idx); } } }
private void startIteration(int[] src, AtomicIntegerArray dst, int[] degrees) { for (int node = 0; node < this.nodeCount; node++) { if (degrees[node] == -1) { continue; } src[node] = toInt(ALPHA * toFloat(dst.getAndSet(node, ONE_MINUS_ALPHA_INT)) / degrees[node]); } }
public int getAndSet(int expected, int newValue) { return unsafeArray.getAndSet(expected, newValue); }
@Override public void clear() { for (int i = 0; i < array.length(); ++i) { int oldValue = array.getAndSet(i, 0); int bitsSet = Integer.bitCount(oldValue); if (bitsSet != 0) { currentSize.addAndGet(-bitsSet); } } }
private synchronized KChunk complex_insert(long universe, long time, long p_obj, KChunk payload, int prehash, int nextValueIndex) { InternalState currentState; InternalState nextState; do { currentState = _state.get(); if (nextValueIndex > currentState._threshold) { nextState = rehashCapacity(currentState); } else { nextState = currentState; } int index = (prehash & 0x7FFFFFFF) % nextState.elementDataSize; nextState.elementK3[(nextValueIndex * 3)] = universe; nextState.elementK3[((nextValueIndex * 3) + 1)] = time; nextState.elementK3[((nextValueIndex * 3) + 2)] = p_obj; nextState.values[nextValueIndex] = payload; nextState.elementNext[nextValueIndex] = nextState.elementHash.getAndSet(index, nextValueIndex); nextState._elementCount.incrementAndGet(); } while (!_state.compareAndSet(currentState, nextState)); return payload; }
private void startIteration(int[] src, AtomicIntegerArray dst, int[] degrees) { for (int node = 0; node < this.nodeCount; node++) { if (degrees[node] == -1) continue; src[node]= toInt(ALPHA * toFloat(dst.getAndSet(node, ONE_MINUS_ALPHA_INT)) / degrees[node]); } }
nextState.elementNext[nextValueIndex] = nextState.elementHash.getAndSet(index, nextValueIndex);
for (int i=0; i < ts.intStore.length(); i++) { synchronized (this.intReadPrepLock[i]) { int delta = ts.intStore.getAndSet(i, 0); if (delta != 0) { this.intStorage.getAndAdd(i, delta);
delta += ts.intStore.getAndSet(idx, 0);