Module stormpot
Package stormpot

Class BasePoolable

  • All Implemented Interfaces:
    Poolable
    Direct Known Subclasses:
    Pooled

    public class BasePoolable
    extends java.lang.Object
    implements Poolable

    A basic implementation of the Poolable interface, which can be extended directly.

    It is not strictly necessary to extend this class in order to implement the Poolable interface, but doing so may make your code simpler.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Slot slot
      The Slot representing this objects place in the pool.
    • Constructor Summary

      Constructors 
      Constructor Description
      BasePoolable​(Slot slot)
      Build a BasePoolable for the given slot.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void expire()
      Explicitly expire this object, such that it will not be claimed again once it is released.
      void release()
      Release this Poolable object back into the pool from where it came, so that others can claim it, or the pool deallocate it if it has expired.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • slot

        protected final Slot slot

        The Slot representing this objects place in the pool. The slot is also the facade for client code to explicitly expire this object, and to release this object back to the pool.

    • Constructor Detail

      • BasePoolable

        public BasePoolable​(Slot slot)

        Build a BasePoolable for the given slot.

        Parameters:
        slot - The Slot that represents this objects place in the pool.
    • Method Detail

      • release

        public void release()
        Description copied from interface: Poolable

        Release this Poolable object back into the pool from where it came, so that others can claim it, or the pool deallocate it if it has expired.

        A call to this method MUST delegate to a call to Slot.release(Poolable) on the Slot object for which this Poolable was allocated, giving itself as the Poolable parameter.

        A Poolable can be released by a thread other than the one that claimed it. It can not, however, be released more than once per claim. The feature of permitting releases from threads other than the claiming thread might be useful in message-passing architectures and the like, but it is not generally recommendable because it makes it more complicated to keep track of object life-cycles.

        Great care must be taken, to ensure that Poolables are not used after they are released!

        Specified by:
        release in interface Poolable
      • expire

        public void expire()

        Explicitly expire this object, such that it will not be claimed again once it is released.

        See Also:
        Slot.expire(Poolable)