java.lang.Object
stormpot.internal.EveryExpiration<T>
- Type Parameters:
T- The concrete poolable type.
- All Implemented Interfaces:
Expiration<T>
The implementation of the
Expiration.every(long, TimeUnit) and
Expiration.every(long, long, TimeUnit) expiration combinators.-
Constructor Summary
ConstructorsConstructorDescriptionEveryExpiration(Expiration<T> innerExpiration, long fromTime, long toTime, TimeUnit unit) Create an instance of the combinator with the given configuration. -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasExpired(SlotInfo<? extends T> info) Test whether the Slot and Poolable object, represented by the givenSlotInfoobject, is still valid, or if the pool should deallocate it and allocate a replacement.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface stormpot.Expiration
every, every, or
-
Constructor Details
-
EveryExpiration
Create an instance of the combinator with the given configuration.- Parameters:
innerExpiration- The inner expiration to wrap.fromTime- The lower expiration time bound.toTime- The upper expiration time bound.unit- The time unit of the bounds.
-
-
Method Details
-
hasExpired
Description copied from interface:ExpirationTest whether the Slot and Poolable object, represented by the givenSlotInfoobject, is still valid, or if the pool should deallocate it and allocate a replacement.If the method throws an exception, then that is taken to mean that the slot is invalid. The exception will bubble out of the
claimmethod, but the mechanism is implementation specific. For this reason, it is generally advised that Expirations do not throw exceptions.Note that this method can be called as often as several times per
claim. The performance of this method therefor has a big influence on the perceived performance of the pool.If this implementation ends up being expensive, then the
every-combinatorcan be used to construct a new expiration object that only performs the expensive check every so often.- 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.- Throws:
Exception- If checking the validity of the Slot or Poolable somehow went wrong. In this case, the Poolable will be assumed to be expired.
-