java.lang.Object
net.i2p.crypto.YKGenerator.YKPrecalcRunner
- All Implemented Interfaces:
Runnable
- Enclosing class:
YKGenerator
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longCheck every 30 seconds whether fewer than the minimum YK pairs remain.private longWall clock time at the end of the previous cycle.private intPool occupancy at the end of the previous cycle.private final intLargest size of the value queue.private final intSmallest size of the value queue.private static final intRefill headroom for a pool that saw no consumption yet, covering the jitter between a drain and this thread noticing it.Constructor Summary
ConstructorsModifierConstructorDescriptionprivateYKPrecalcRunner(int minSize, int maxSize) Builds one precalculation runner.Method Summary
Modifier and TypeMethodDescriptionprivate intrefillTarget(int drained, long elapsedMs) How far above the minimum to refill: scoped to one check interval's worth of observed consumption, so the expensive modular exponentiations track real demand.voidrun()Precalculate YK pairs until the generator is stopped.
Field Details
MIN_SLACK
private static final int MIN_SLACKRefill headroom for a pool that saw no consumption yet, covering the jitter between a drain and this thread noticing it.- See Also:
_minSize
private final int _minSizeSmallest size of the value queue._maxSize
private final int _maxSizeLargest size of the value queue._checkDelay
private long _checkDelayCheck every 30 seconds whether fewer than the minimum YK pairs remain._lastSize
private int _lastSizePool occupancy at the end of the previous cycle._lastSample
private long _lastSampleWall clock time at the end of the previous cycle.
Constructor Details
YKPrecalcRunner
private YKPrecalcRunner(int minSize, int maxSize) Builds one precalculation runner.- Parameters:
minSize- the smallest size of the value queuemaxSize- the largest size of the value queue
Method Details
run
refillTarget
private int refillTarget(int drained, long elapsedMs) How far above the minimum to refill: scoped to one check interval's worth of observed consumption, so the expensive modular exponentiations track real demand. Only consulted once the pool is already below the minimum, so it never changes when a refill starts, only how far it goes.- Parameters:
drained- how many values the pool lost since the previous cycleelapsedMs- how long ago the previous cycle ended- Returns:
- the size to fill to, never above the configured maximum