Top Description Fields Constructors Methods
stormpot

pack-priv final Class TimeSpreadExpiration<T extends Poolable>

extends Object
implements Expiration<T extends Poolable>
Class Inheritance
All Implemented Interfaces
stormpot.Expiration
Imports
java.util.Objects, java.util.concurrent.ThreadLocalRandom, .TimeUnit

This is the standard time based Expiration. It will invalidate objects based on about how long ago they were allocated.
Author
Chris Vest
Since
2.2

Field Summary

Modifier and TypeField and Description
private final long
private final long
private final TimeUnit

Constructor Summary

AccessConstructor and Description
pack-priv
TimeSpreadExpiration(long
Poolables younger than this, in the given unit, are not considered expired. This value must be at least 1.
lowerBound
,
long
Poolables older than this, in the given unit, are always considered expired. This value must be greater than the lowerBound.
upperBound
,
TimeUnit
The TimeUnit of the bounds values. Never `null`.
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 TypeMethod and Description
pack-priv long
public boolean
hasExpired(SlotInfo<? extends T>
An informative representative of the slot being tested. Never `null`.
info
)

Implements stormpot.Expiration.hasExpired.

Returns `true`, with uniformly increasing probability, if the stormpot.Poolable represented by the given SlotInfo is older than the lower bound, eventually returning `true` with 100% certainty when the age of the Poolable is equal to or greater than the upper bound.
public String
toString()

Overrides java.lang.Object.toString.

Produces a String representation of this TimeSpreadExpiration.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

fromMillisback to summary
private final long fromMillis
toMillisback to summary
private final long toMillis
unitback to summary
private final TimeUnit unit

Constructor Detail

TimeSpreadExpirationback to summary
pack-priv TimeSpreadExpiration(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. If the `lowerBound` is less than 1, the `upperBound` is less than the `lowerBound`, or the `unit` is `null`, then an java.lang.IllegalArgumentException will be thrown.

Parameters
lowerBound:long

Poolables younger than this, in the given unit, are not considered expired. This value must be at least 1.

upperBound:long

Poolables older than this, in the given unit, are always considered expired. This value must be greater than the lowerBound.

unit:TimeUnit

The TimeUnit of the bounds values. Never `null`.

Method Detail

computeExpirationDeadlineback to summary
pack-priv long computeExpirationDeadline()
hasExpiredback to summary
public boolean hasExpired(SlotInfo<? extends T> info)

Implements stormpot.Expiration.hasExpired.

Returns `true`, with uniformly increasing probability, if the stormpot.Poolable represented by the given SlotInfo is older than the lower bound, eventually returning `true` with 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.

Parameters
info:SlotInfo<? extends T>

Doc from stormpot.Expiration.hasExpired.

An informative representative of the slot being tested. Never `null`.

Returns:boolean

Doc from stormpot.Expiration.hasExpired.

`true` if the Slot and Poolable in question should be deallocated, `false` if it is valid and eligible for claiming.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Produces a String representation of this TimeSpreadExpiration.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object

Annotations
@Override