Skip to content

Commit

Permalink
renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-bukhtoyarov committed Apr 29, 2016
1 parent 00e0aaa commit f1708d6
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public ResetByChunksAccumulator(Supplier<Recorder> recorderSupplier, int numberC
@Override
public void recordSingleValueWithExpectedInterval(long value, long expectedIntervalBetweenValueSamples) {
long currentTimeMillis = clock.getTime();
recordValue(value, expectedIntervalBetweenValueSamples, currentTimeMillis, true);
recordOrTouch(value, expectedIntervalBetweenValueSamples, currentTimeMillis, true);
}

@Override
Expand All @@ -92,7 +92,7 @@ public final synchronized Snapshot getSnapshot(Function<Histogram, Snapshot> sna
if (phase.proposedInvalidationTimestamp <= currentTimeMillis) {
// detected that reservoir was unused by writer for a long time
// lets record fake value in order to trigger the rotation process
recordValue(FAKE_VALUE, 0, currentTimeMillis, false);
recordOrTouch(FAKE_VALUE, 0, currentTimeMillis, false);
}
if (reportUncompletedChunkToSnapshot) {
phase.intervalHistogram = phase.recorder.getIntervalHistogram(phase.intervalHistogram);
Expand All @@ -117,17 +117,17 @@ public final synchronized Snapshot getSnapshot(Function<Histogram, Snapshot> sna
return snapshotTaker.apply(temporarySnapshotHistogram);
}

private void recordValue(long value, long expectedIntervalBetweenValueSamples, long currentTimeMillis, boolean currentThreadIsWriter) {
private void recordOrTouch(long value, long expectedIntervalBetweenValueSamples, long currentTimeMillis, boolean currentThreadIsWriter) {
Phase currentPhase = currentPhaseRef.get();
if (currentTimeMillis < currentPhase.proposedInvalidationTimestamp) {
if (value != FAKE_VALUE) {
if (currentThreadIsWriter) {
currentPhase.recorder.recordValueWithExpectedInterval(value, expectedIntervalBetweenValueSamples);
}
return;
}

Phase nextPhase = currentPhase == left ? right : left;
if (value != FAKE_VALUE) {
if (currentThreadIsWriter) {
nextPhase.recorder.recordValueWithExpectedInterval(value, expectedIntervalBetweenValueSamples);
}
if (!currentPhaseRef.compareAndSet(currentPhase, nextPhase)) {
Expand Down

0 comments on commit f1708d6

Please sign in to comment.