Class GammaObjectPool


  • public final class GammaObjectPool
    extends java.lang.Object
    A pool for tranlocals. The pool is not threadsafe and should be connected to a thread (can be stored in a threadlocal). Eventually the performance of the stm will be limited to the rate of cleanup, and using a pool seriously improves scalability.

    Improvement: atm there is only one single type of tranlocal. If there are more types of tranlocals, each class needs to have an index. This index can be used to determine the type of ref. If the pool contains an array of arrays, where the first array is index based on the type of the ref, finding the second array (that contains pooled tranlocals) can be found easily.

    ObjectPool is not thread safe and should not be shared between threads.

    This class is generated.

    • Field Detail

      • ENABLED

        private static final boolean ENABLED
      • TRANLOCAL_POOLING_ENABLED

        private static final boolean TRANLOCAL_POOLING_ENABLED
      • TRANLOCALARRAY_POOLING_ENABLED

        private static final boolean TRANLOCALARRAY_POOLING_ENABLED
      • LISTENER_POOLING_ENABLED

        private static final boolean LISTENER_POOLING_ENABLED
      • LISTENERSARRAY_POOLING_ENABLED

        private static final boolean LISTENERSARRAY_POOLING_ENABLED
      • ARRAYLIST_POOLING_ENABLED

        private static final boolean ARRAYLIST_POOLING_ENABLED
      • CALLABLENODE_POOLING_ENABLED

        private static final boolean CALLABLENODE_POOLING_ENABLED
      • tranlocalPoolingEnabled

        private final boolean tranlocalPoolingEnabled
      • tranlocalArrayPoolingEnabled

        private final boolean tranlocalArrayPoolingEnabled
      • listenersPoolingEnabled

        private final boolean listenersPoolingEnabled
      • listenersArrayPoolingEnabled

        private final boolean listenersArrayPoolingEnabled
      • arrayListPoolingEnabled

        private final boolean arrayListPoolingEnabled
      • callableNodePoolingEnabled

        private final boolean callableNodePoolingEnabled
      • tranlocals

        private final Tranlocal[] tranlocals
      • lastUsedGammaTxnRef

        private int lastUsedGammaTxnRef
      • listenersPool

        private final Listeners[] listenersPool
      • listenersPoolIndex

        private int listenersPoolIndex
      • arrayListPool

        private final java.util.ArrayList[] arrayListPool
      • arrayListPoolIndex

        private int arrayListPoolIndex
      • callableNodePool

        private final CallableNode[] callableNodePool
      • callableNodePoolIndex

        private int callableNodePoolIndex
      • tranlocalArrayPool

        private Tranlocal[][] tranlocalArrayPool
      • listenersArray

        private Listeners[] listenersArray
    • Constructor Detail

      • GammaObjectPool

        public GammaObjectPool()
    • Method Detail

      • take

        public Tranlocal take​(BaseGammaTxnRef owner)
        Takes a Tranlocal from the pool for the specified GammaTxnRef.
        Parameters:
        owner - the GammaTxnRef to get the Tranlocal for.
        Returns:
        the pooled tranlocal, or null if none is found.
        Throws:
        java.lang.NullPointerException - if owner is null.
      • put

        public void put​(Tranlocal tranlocal)
        Puts an old Tranlocal in this pool. If the tranlocal is allowed to be null, the call is ignored. The same goes for when the tranlocal is permanent, since you can't now how many transactions are still using it.
        Parameters:
        tranlocal - the Tranlocal to pool.
      • putTranlocalArray

        public void putTranlocalArray​(Tranlocal[] array)
        Puts a GammaTranlocal array in the pool.
        Parameters:
        array - the GammaTranlocal array to put in the pool.
        Throws:
        java.lang.NullPointerException - is array is null.
      • takeTranlocalArray

        public Tranlocal[] takeTranlocalArray​(int size)
        Takes a tranlocal array from the pool with the given size.
        Parameters:
        size - the size of the array to take
        Returns:
        the GammaTranlocal array taken from the pool, or null if none available.
        Throws:
        java.lang.IllegalArgumentException - if size smaller than 0.
      • takeCallableNode

        public CallableNode takeCallableNode()
        Takes a CallableNode from the pool, or null if none is available.
        Returns:
        the CallableNode from the pool, or null if none available.
      • putCallableNode

        public void putCallableNode​(CallableNode node)
        Puts a CallableNode in the pool.
        Parameters:
        node - the CallableNode to pool.
        Throws:
        java.lang.NullPointerException - if node is null.
      • takeArrayList

        public java.util.ArrayList takeArrayList()
        Takes an ArrayList from the pool, The returned ArrayList is cleared.
        Returns:
        the ArrayList from the pool, or null of none is found.
      • putArrayList

        public void putArrayList​(java.util.ArrayList list)
        Puts an ArrayList in this pool. The ArrayList will be cleared before being placed in the pool.
        Parameters:
        list - the ArrayList to place in the pool.
        Throws:
        java.lang.NullPointerException - if list is null.
      • takeListeners

        public Listeners takeListeners()
        Takes a Listeners object from the pool.
        Returns:
        the Listeners object taken from the pool. or null if none is taken.
      • putListeners

        public void putListeners​(Listeners listeners)
        Puts a Listeners object in the pool. The Listeners object is preparedForPooling before it is put in the pool. The next Listeners object is ignored (the next field itself is ignored).
        Parameters:
        listeners - the Listeners object to pool.
        Throws:
        java.lang.NullPointerException - is listeners is null.
      • takeListenersArray

        public Listeners[] takeListenersArray​(int minimalSize)
        Takes a Listeners array from the pool. If an array is returned, it is completely nulled.
        Parameters:
        minimalSize - the minimalSize of the Listeners array.
        Returns:
        the found Listeners array, or null if none is taken from the pool.
        Throws:
        java.lang.IllegalArgumentException - if minimalSize is smaller than 0.
      • putListenersArray

        public void putListenersArray​(Listeners[] listenersArray)
        Puts a Listeners array in the pool.

        Listeners array should be nulled before being put in the pool. It is not going to be done by this GammaObjectPool but should be done when the listeners on the listeners array are notified.

        Parameters:
        listenersArray - the array to pool.
        Throws:
        java.lang.NullPointerException - if listenersArray is null.