java.lang.Object
stormpot.internal.TimeSpreadExpiration<T>
- Type Parameters:
T- The concrete poolable type.
- All Implemented Interfaces:
Expiration<T>
This is the standard time based
Expiration. It will invalidate
objects based on about how long ago they were allocated.- Since:
- 2.2
- Author:
- Chris Vest
-
Constructor Summary
ConstructorsConstructorDescriptionTimeSpreadExpiration(long lowerBound, long upperBound, TimeUnit unit) Construct a new Expiration that will invalidate objects that are older than the given lower bound, before they get older than the upper bound, in the given time unit. -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasExpired(SlotInfo<? extends T> info) toString()Produces a String representation of this TimeSpreadExpiration.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface stormpot.Expiration
every, every, or
-
Constructor Details
-
TimeSpreadExpiration
Construct a new Expiration that will invalidate objects that are older than the given lower bound, before they get older than the upper bound, in the given time unit.If the
lowerBoundis less than 1, theupperBoundis less than thelowerBound, or theunitisnull, then anIllegalArgumentExceptionwill be thrown.- Parameters:
lowerBound- Poolables younger than this, in the given unit, are not considered expired. This value must be at least 1.upperBound- Poolables older than this, in the given unit, are always considered expired. This value must be greater than the lowerBound.unit- TheTimeUnitof the bounds values. Nevernull.
-
-
Method Details
-
hasExpired
Returnstrue, with uniformly increasing probability, if thePoolablerepresented by the givenSlotInfois older than the lower bound, eventually returningtruewith 100% certainty when the age of the Poolable is equal to or greater than the upper bound.The uniformity of the random expiration holds regardless of how often a Poolable is checked. That is to say, checking a Poolable more times within an interval of time, does _not_ increase its chances of being declared expired.
- Specified by:
hasExpiredin interfaceExpiration<T extends Poolable>- Parameters:
info- An informative representative of the slot being tested. Nevernull.- Returns:
trueif the Slot and Poolable in question should be deallocated,falseif it is valid and eligible for claiming.
-
toString
Produces a String representation of this TimeSpreadExpiration.
-