If nearestAllowed is in past, that means we have
a temporary interval of relatively small demand for tasks.
We can reduce delay, as if the time since nearestAllowed
was a "delay in advance".
This way the queue stays closer to the intended capacity.
Change-Id: I40f95ea9cb25ea62d8c65ee78cafc79e9b56cc11
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
* @return estimated tick number when all threads with opened tasks are done waiting
*/
public long estimateAllowed(final long now) {
- return Math.max(now, nearestAllowed) + estimateIsolatedDelay(now);
+ return Math.max(now, nearestAllowed + estimateIsolatedDelay(now));
}
// State-altering public methods.