Module stormpot
Package stormpot

Interface SlotInfo<T extends Poolable>

Type Parameters:
T - The type of Poolables that this Expiration is able to examine.
All Known Implementing Classes:
BSlot, BSlotPadded

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
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Get the approximate number of milliseconds that have transpired since the object was allocated.
    long
    Get the approximate System.nanoTime() timestamp for when the object was allocated.
    Get the Poolable object represented by this SlotInfo instance.
    long
    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 Details

    • 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.
    • getCreatedNanoTime

      long getCreatedNanoTime()
      Get the approximate System.nanoTime() timestamp for when the object was allocated.
      Returns:
      The object allocation System.nanoTime() timestamp.
    • getPoolable

      T getPoolable()
      Get the Poolable object represented by this SlotInfo instance.

      WARNING: Do not release() Poolables from within an Expiration — doing so is a user error, and the behaviour of the pool in such a situation is unspecified and implementation specific. This means that deadlocks and infinite loops are possible outcomes as well.

      WARNING: Also 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.