Commit 74dadae5 by tonihei Committed by Oliver Woodman

Make values forwarded to bandwidth listener final again.

When notifying the bandwidth listeners of new samples, the forwarded values
need to be final to prevent concurrent access. Putting the event forwarding
into a separate method ensures the values are final.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=204877650
parent b25a1242
......@@ -226,13 +226,14 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
bitrateEstimate = (long) slidingPercentile.getPercentile(0.5f);
}
}
eventDispatcher.dispatch(
listener ->
listener.onBandwidthSample(
sampleElapsedTimeMs, sampleBytesTransferred, bitrateEstimate));
notifyBandwidthSample(sampleElapsedTimeMs, sampleBytesTransferred, bitrateEstimate);
if (--streamCount > 0) {
sampleStartTimeMs = nowMs;
}
sampleBytesTransferred = 0;
}
private void notifyBandwidthSample(int elapsedMs, long bytes, long bitrate) {
eventDispatcher.dispatch(listener -> listener.onBandwidthSample(elapsedMs, bytes, bitrate));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment