Documentation of 'javolution37.javolution.realtime.ObjectPool' Java class
ObjectPool
javolution37.javolution.realtime

Class ObjectPool<T>



  • public abstract class ObjectPool<T>
    extends java.lang.Object

    This abstract class represents an object pool managed by a PoolContext.

    Pool objects are always allocated in the same memory area as the pool object itself. In other words, NoHeapRealtimeThread executing in ScopedMemory can safely use pools allocated in ImmortalMemory.

    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static ObjectPool NULL
      Holds a pool returning null values.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method and Description
      ObjectPool<T> getOuter()
      Returns the outer pool of this pool.
      java.lang.Thread getUser()
      Returns the current user of this pool or null if none.
      boolean inUse()
      Indicates if this pool is in use.
      boolean isLocal()
      Indicates if this pool is actively used by the current thread.
      abstract T next()
      Returns the next available object from this pool.
      abstract void recycle(T obj)
      Recycles the specified object.
      abstract int size()
      Returns the number of objects held by this pool.
      • Methods inherited from class java.lang.Object

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

      • NULL

        public static final ObjectPool NULL
        Holds a pool returning null values.
    • Method Detail

      • getUser

        public final java.lang.Thread getUser()
        Returns the current user of this pool or null if none.
        Returns:
        the pool current user.
      • isLocal

        public final boolean isLocal()
        Indicates if this pool is actively used by the current thread. The framework ensures that local pools are visible to their users only (concurrent executions are performed in an inner pool context). Operations on local pools are therefore thread-safe without requiring synchronization.
        Returns:
        true if this pool is local for the current thread; false otherwise.
        Throws:
        JavolutionError - if this operation is called upon a pool not currently in use.
      • inUse

        public final boolean inUse()
        Indicates if this pool is in use. A pool can be in use and not having a current user if the user has entered an inner pool.
        Returns:
        true if at least one thread has been allocating from this pool; false if this pool is not being used at all (e.g. inner pool).
      • getOuter

        public final ObjectPool<T> getOuter()
        Returns the outer pool of this pool.
        Returns:
        the outer pool or null if the outer is the heap.
      • size

        public abstract int size()
        Returns the number of objects held by this pool.
        Returns:
        this pool size.
      • next

        public abstract T next()
        Returns the next available object from this pool. If there is none, a new object is allocated from the same memory area as this pool, added to the pool and then returned.
        Returns:
        the next available object from this pool.
      • recycle

        public abstract void recycle(T obj)
        Recycles the specified object. Callers should make sure that the recycled object is not going to be referenced anymore (in a heap context it would be garbage collected).
        Parameters:
        obj - the object to recycle to this pool.
        Throws:
        java.lang.IllegalArgumentException - if the specified object do not belong to the pool.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.