-
- Type Parameters:
T
- The type of Poolables that this Expiration is able to examine.
public interface SlotInfo<T extends Poolable>
An informative interface, used by
Expiration
instances to determine if a slot has expired or is still invalid for claiming.- Author:
- Chris Vest <mr.chrisvest@gmail.com>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description long
getAgeMillis()
Get the approximate number of milliseconds that have transpired since the object was allocated.long
getClaimCount()
Get the number of times the object has been claimed since it was allocated.T
getPoolable()
Get the Poolable object represented by this SlotInfo instance.long
getStamp()
Get the stamp value that has been set on this SlotInfo, or 0 if none has been set since the Poolable was allocated.void
setStamp(long stamp)
Set the stamp value on this SlotInfo.
-
-
-
Method Detail
-
getAgeMillis
long getAgeMillis()
Get the approximate number of milliseconds that have transpired since the object was allocated.
- Returns:
- The age of the object in milliseconds.
-
getClaimCount
long getClaimCount()
Get the number of times the object has been claimed since it was allocated.
- Returns:
- The objects claim count.
-
getPoolable
T getPoolable()
Get the Poolable object represented by this SlotInfo instance.
WarningDo not release()
Poolables from within anExpiration
— doing so is a user error, and the behaviour of the pool in such a situation is unspecified and implementation specific. This means that dead-locks and infinite loops are possible outcomes as well.WarningAlso note that accessing the Poolable through this method, from your Expiration
implementation, is a potentially concurrent access. This means that you need to take thread-safety issues into consideration - especially if you intend on manipulating the Poolable. In particular, you might be racing with other threads that are checking if this Poolable is expired or not, and they might even have claimed the Poolable and put it to use, by the time it is returned from this method.- Returns:
- The Poolable being examined for validity. Never
null
.
-
getStamp
long getStamp()
Get the stamp value that has been set on this SlotInfo, or 0 if none has been set since the Poolable was allocated.
Apart from the zero-value, the actual meaning of this value is completely up to the
Expiration
that sets it.- Returns:
- The current stamp value.
-
setStamp
void setStamp(long stamp)
Set the stamp value on this SlotInfo.
This method is only thread-safe to call from within the scope of the
Expiration.hasExpired(SlotInfo)
method.The stamp value is 0 by default, if it has not been set after the Poolable has been allocated. Its meaning is otherwise up to the particular Expiration that might use it.
- Parameters:
stamp
- The new stamp value.
-
-