Class PooledResource<T>

  • Type Parameters:
    T - resource type
    All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class PooledResource<T>
    extends CloseableResource<T>
    A pooled resource that was acquired from a Pool, and will be released back to the pool when it's closed. If the resource is leaked from the pool, the resource will be closed if it's closeable.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.ref.WeakReference<Pool<T>> mPool  
      protected java.lang.String mPoolDescription  
    • Constructor Summary

      Constructors 
      Constructor Description
      PooledResource​(T resource, Pool<T> pool)
      Creates a new pooled resource with the pool from which it was acquired.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void closeResource()
      Performs any cleanup operations necessary when the resource is no longer in use.
      • Methods inherited from class java.lang.Object

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

      • mPool

        protected final java.lang.ref.WeakReference<Pool<T>> mPool
      • mPoolDescription

        protected final java.lang.String mPoolDescription
    • Constructor Detail

      • PooledResource

        public PooledResource​(T resource,
                              Pool<T> pool)
        Creates a new pooled resource with the pool from which it was acquired.
        Parameters:
        resource - the resource
        pool - the pool where the resource was acquired
    • Method Detail