@Test public void smoke() { long currentTime = 0; long minDelayThreshold = 4; long maxDelayThreshold = 8; DefaultInvocationGate gate = new DefaultInvocationGate(minDelayThreshold, maxDelayThreshold, currentTime); assertTrue(gate.isTooSoon(0)); }
@Override final public boolean isTooSoon(long currentTime) { boolean maskMatch = ((invocationCounter++) & mask) == mask; if (maskMatch) { if (currentTime < this.lowerLimitForMaskMatch) { increaseMask(); } updateLimits(currentTime); } else { if (currentTime > this.upperLimitForNoMaskMatch) { decreaseMask(); updateLimits(currentTime); return false; } } return !maskMatch; }
DefaultInvocationGate implements InvocationGate { @Override final public boolean isTooSoon(long currentTime) { boolean maskMatch = ((invocationCounter++) & mask) == mask; if (maskMatch) { if (currentTime < this.lowerLimitForMaskMatch) { increaseMask(); } updateLimits(currentTime); } else { if (currentTime > this.upperLimitForNoMaskMatch) { decreaseMask(); updateLimits(currentTime); return false; } } return !maskMatch; } }
DefaultInvocationGate implements InvocationGate { @Override final public boolean isTooSoon(long currentTime) { boolean maskMatch = ((invocationCounter++) & mask) == mask; if (maskMatch) { if (currentTime < this.lowerLimitForMaskMatch) { increaseMask(); } updateLimits(currentTime); } else { if (currentTime > this.upperLimitForNoMaskMatch) { decreaseMask(); updateLimits(currentTime); return false; } } return !maskMatch; } DefaultInvocationGate();  DefaultInvocationGate(long minDelayThreshold, long maxDelayThreshold, long currentTime); }
DefaultInvocationGate implements InvocationGate { @Override final public boolean isTooSoon(long currentTime) { boolean maskMatch = ((invocationCounter++) & mask) == mask; if (maskMatch) { if (currentTime < this.lowerLimitForMaskMatch) { increaseMask(); } updateLimits(currentTime); } else { if (currentTime > this.upperLimitForNoMaskMatch) { decreaseMask(); updateLimits(currentTime); return false; } } return !maskMatch; } DefaultInvocationGate();  DefaultInvocationGate(long minDelayThreshold, long maxDelayThreshold, long currentTime); @Override final boolean isTooSoon(long currentTime); long getInvocationCounter(); }
DefaultInvocationGate implements InvocationGate { @Override final public boolean isTooSoon(long currentTime) { boolean maskMatch = ((invocationCounter++) & mask) == mask; if (maskMatch) { if (currentTime < this.lowerLimitForMaskMatch) { increaseMask(); } updateLimits(currentTime); } else { if (currentTime > this.upperLimitForNoMaskMatch) { decreaseMask(); updateLimits(currentTime); return false; } } return !maskMatch; } DefaultInvocationGate();  DefaultInvocationGate(long minDelayThreshold, long maxDelayThreshold, long currentTime); @Override final boolean isTooSoon(long currentTime); long getInvocationCounter();  }