@Override synchronized void fillBufferFromCountsArray(final ByteBuffer buffer) { try { wrp.readerLock(); super.fillBufferFromCountsArray(buffer); } finally { wrp.readerUnlock(); } }
@Override void setCountAtNormalizedIndex(final int index, final long value) { try { wrp.readerLock(); assert (countsArrayLength == activeCounts.length()); assert (countsArrayLength == inactiveCounts.length()); inactiveCounts.lazySet(index, value); activeCounts.lazySet(index, 0); } finally { wrp.readerUnlock(); } }
@Override long getCountAtNormalizedIndex(final int index) { try { wrp.readerLock(); assert (countsArrayLength == activeCounts.length()); assert (countsArrayLength == inactiveCounts.length()); long activeCount = activeCounts.get(index); long inactiveCount = inactiveCounts.get(index); return activeCount + inactiveCount; } finally { wrp.readerUnlock(); } }
@Override void setIntegerToDoubleValueConversionRatio(final double integerToDoubleValueConversionRatio) { try { wrp.readerLock(); inactiveCounts.doubleToIntegerValueConversionRatio = 1.0 / integerToDoubleValueConversionRatio; // switch active and inactive: AtomicLongArrayWithNormalizingOffset tmp = activeCounts; activeCounts = inactiveCounts; inactiveCounts = tmp; wrp.flipPhase(); inactiveCounts.doubleToIntegerValueConversionRatio = 1.0 / integerToDoubleValueConversionRatio; // switch active and inactive again: tmp = activeCounts; activeCounts = inactiveCounts; inactiveCounts = tmp; wrp.flipPhase(); // At this point, both active and inactive have normalizingIndexOffset safely set, // and the switch in each was done without any writers using the wrong value in flight. } finally { wrp.readerUnlock(); } super.setIntegerToDoubleValueConversionRatio(integerToDoubleValueConversionRatio); }
private void performIntervalSample() { try { recordingPhaser.readerLock(); // Make sure we have an inactive version to flip in: if (inactiveHistogram == null) { inactiveHistogram = new InternalHistogram(activeHistogram); } inactiveHistogram.reset(); // Swap active and inactive histograms: final InternalHistogram tempHistogram = inactiveHistogram; inactiveHistogram = activeHistogram; activeHistogram = tempHistogram; // Mark end time of previous interval and start time of new one: long now = System.currentTimeMillis(); activeHistogram.setStartTimeStamp(now); inactiveHistogram.setEndTimeStamp(now); // Make sure we are not in the middle of recording a value on the previously active histogram: // Flip phase to make sure no recordings that were in flight pre-flip are still active: recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */); } finally { recordingPhaser.readerUnlock(); } }
private void performIntervalSample() { try { recordingPhaser.readerLock(); // Make sure we have an inactive version to flip in: if (inactiveHistogram == null) { inactiveHistogram = new InternalDoubleHistogram(activeHistogram); } inactiveHistogram.reset(); // Swap active and inactive histograms: final InternalDoubleHistogram tempHistogram = inactiveHistogram; inactiveHistogram = activeHistogram; activeHistogram = tempHistogram; // Mark end time of previous interval and start time of new one: long now = System.currentTimeMillis(); activeHistogram.setStartTimeStamp(now); inactiveHistogram.setEndTimeStamp(now); // Make sure we are not in the middle of recording a value on the previously active histogram: // Flip phase to make sure no recordings that were in flight pre-flip are still active: recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */); } finally { recordingPhaser.readerUnlock(); } }
private void performIntervalSample() { try { recordingPhaser.readerLock(); // Make sure we have an inactive version to flip in: if (inactiveHistogram == null) { inactiveHistogram = new InternalConcurrentDoubleHistogram(activeHistogram); } inactiveHistogram.reset(); // Swap active and inactive histograms: final InternalConcurrentDoubleHistogram tempHistogram = inactiveHistogram; inactiveHistogram = activeHistogram; activeHistogram = tempHistogram; // Mark end time of previous interval and start time of new one: long now = System.currentTimeMillis(); activeHistogram.setStartTimeStamp(now); inactiveHistogram.setEndTimeStamp(now); // Make sure we are not in the middle of recording a value on the previously active histogram: // Flip phase to make sure no recordings that were in flight pre-flip are still active: recordingPhaser.flipPhase(500000L /* yield in 0.5 msec units if needed */); } finally { recordingPhaser.readerUnlock(); } }
@Override void shiftNormalizingIndexByOffset(final int offsetToAdd, final boolean lowestHalfBucketPopulated, final double newIntegerToDoubleValueConversionRatio) { try { wrp.readerLock(); assert (countsArrayLength == activeCounts.length()); assert (countsArrayLength == inactiveCounts.length()); int newNormalizingIndexOffset = getNormalizingIndexOffset() + offsetToAdd; setNormalizingIndexOffset(newNormalizingIndexOffset, offsetToAdd, lowestHalfBucketPopulated, newIntegerToDoubleValueConversionRatio ); } finally { wrp.readerUnlock(); } }
@Override void clearCounts() { try { wrp.readerLock(); assert (countsArrayLength == activeCounts.length()); assert (countsArrayLength == inactiveCounts.length()); for (int i = 0; i < activeCounts.length(); i++) { activeCounts.lazySet(i, 0); inactiveCounts.lazySet(i, 0); } totalCountUpdater.set(this, 0); } finally { wrp.readerUnlock(); } }
private void performIntervalSample() { try { recordingPhaser.readerLock();
@Override void setCountAtIndex(final int index, final long value) { try { wrp.readerLock(); assert (countsArrayLength == activeCounts.length()); assert (countsArrayLength == inactiveCounts.length()); activeCounts.lazySet( normalizeIndex(index, activeCounts.getNormalizingIndexOffset(), activeCounts.length()), value); inactiveCounts.lazySet( normalizeIndex(index, inactiveCounts.getNormalizingIndexOffset(), inactiveCounts.length()), 0); } finally { wrp.readerUnlock(); } }
@Override long getCountAtIndex(final int index) { try { wrp.readerLock(); assert (countsArrayLength == activeCounts.length()); assert (countsArrayLength == inactiveCounts.length()); long activeCount = activeCounts.get( normalizeIndex(index, activeCounts.getNormalizingIndexOffset(), activeCounts.length())); long inactiveCount = inactiveCounts.get( normalizeIndex(index, inactiveCounts.getNormalizingIndexOffset(), inactiveCounts.length())); return activeCount + inactiveCount; } finally { wrp.readerUnlock(); } }
@Override void resize(final long newHighestTrackableValue) { try { wrp.readerLock();
final double newIntegerToDoubleValueConversionRatio) { try { wrp.readerLock();
@Override synchronized void fillBufferFromCountsArray(final ByteBuffer buffer) { try { wrp.readerLock(); super.fillBufferFromCountsArray(buffer); } finally { wrp.readerUnlock(); } }
/** * Place a copy of the values of the latest uncorrected interval latency histogram. Values will not include * corrections for detected pauses. The interval histogram copies will include all values points * captured up to the latest call to call to one of {@link #getIntervalHistogram}, * {@link #getIntervalHistogramInto}, or {@link #addIntervalHistogramTo}. * * @param targetHistogram the histogram into which the interval histogram's data should be copied */ public synchronized void getLatestUncorrectedIntervalHistogramInto(Histogram targetHistogram) { try { recordingPhaser.readerLock(); inactiveRawDataHistogram.copyInto(targetHistogram); } finally { recordingPhaser.readerUnlock(); } }
@Override void setCountAtNormalizedIndex(final int index, final long value) { try { wrp.readerLock(); assert (countsArrayLength == activeCounts.length()); assert (countsArrayLength == inactiveCounts.length()); inactiveCounts.lazySet(index, value); activeCounts.lazySet(index, 0); } finally { wrp.readerUnlock(); } }
@Override long getCountAtNormalizedIndex(final int index) { try { wrp.readerLock(); assert (countsArrayLength == activeCounts.length()); assert (countsArrayLength == inactiveCounts.length()); long activeCount = activeCounts.get(index); long inactiveCount = inactiveCounts.get(index); return activeCount + inactiveCount; } finally { wrp.readerUnlock(); } }
@Override void setCountAtIndex(final int index, final long value) { try { wrp.readerLock(); assert (countsArrayLength == activeCounts.length()); assert (countsArrayLength == inactiveCounts.length()); activeCounts.lazySet( normalizeIndex(index, activeCounts.getNormalizingIndexOffset(), activeCounts.length()), value); inactiveCounts.lazySet( normalizeIndex(index, inactiveCounts.getNormalizingIndexOffset(), inactiveCounts.length()), 0); } finally { wrp.readerUnlock(); } }
@Override long getCountAtIndex(final int index) { try { wrp.readerLock(); assert (countsArrayLength == activeCounts.length()); assert (countsArrayLength == inactiveCounts.length()); long activeCount = activeCounts.get( normalizeIndex(index, activeCounts.getNormalizingIndexOffset(), activeCounts.length())); long inactiveCount = inactiveCounts.get( normalizeIndex(index, inactiveCounts.getNormalizingIndexOffset(), inactiveCounts.length())); return activeCount + inactiveCount; } finally { wrp.readerUnlock(); } }