org.multiverse.stms.gamma

## Class GammaObjectPool

- java.lang.Object
- - org.multiverse.stms.gamma.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.

### Constructor Summary

Constructors
Constructor and Description
`GammaObjectPool()`

### Method Summary

Methods
`void` `put(Tranlocal tranlocal)` Puts an old Tranlocal in this pool.
`void` `putArrayList(java.util.ArrayList list)` Puts an ArrayList in this pool.
`void` `putCallableNode(CallableNode node)` Puts a CallableNode in the pool.
`void` `putListeners(Listeners listeners)` Puts a Listeners object in the pool.
`void` `putListenersArray(Listeners[] listenersArray)` Puts a Listeners array in the pool.
`void` `putTranlocalArray(Tranlocal[] array)` Puts a GammaTranlocal array in the pool.
`Tranlocal` `take(BaseGammaTxnRef owner)` Takes a Tranlocal from the pool for the specified GammaTxnRef.
`java.util.ArrayList` `takeArrayList()` Takes an ArrayList from the pool, The returned ArrayList is cleared.
`CallableNode` `takeCallableNode()` Takes a CallableNode from the pool, or null if none is available.
`Listeners` `takeListeners()` Takes a Listeners object from the pool.
`Listeners[]` `takeListenersArray(int minimalSize)` Takes a Listeners array from the pool.
`Tranlocal[]` `takeTranlocalArray(int size)` Takes a tranlocal array from the pool with the given size.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 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.