Package org.multiverse.stms.gamma
Class GammaObjectPool
java.lang.Object
org.multiverse.stms.gamma.GammaObjectPool
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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final boolean
private final ArrayList[]
private int
private final boolean
private static final boolean
private final CallableNode[]
private int
private final boolean
private static final boolean
private int
private static final boolean
private Listeners[]
private static final boolean
private final boolean
private final Listeners[]
private int
private final boolean
private static final boolean
private static final boolean
private Tranlocal[][]
private final boolean
private final boolean
private final Tranlocal[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Puts an old Tranlocal in this pool.void
putArrayList
(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.take
(BaseGammaTxnRef owner) Takes a Tranlocal from the pool for the specified GammaTxnRef.Takes an ArrayList from the pool, The returned ArrayList is cleared.Takes a CallableNode from the pool, or null if none is available.Takes a Listeners object from the pool.takeListenersArray
(int minimalSize) Takes a Listeners array from the pool.takeTranlocalArray
(int size) Takes a tranlocal array from the pool with the given size.
-
Field Details
-
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
-
lastUsedGammaTxnRef
private int lastUsedGammaTxnRef -
listenersPool
-
listenersPoolIndex
private int listenersPoolIndex -
arrayListPool
-
arrayListPoolIndex
private int arrayListPoolIndex -
callableNodePool
-
callableNodePoolIndex
private int callableNodePoolIndex -
tranlocalArrayPool
-
listenersArray
-
-
Constructor Details
-
GammaObjectPool
public GammaObjectPool()
-
-
Method Details
-
take
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:
NullPointerException
- if owner is null.
-
put
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
Puts a GammaTranlocal array in the pool.- Parameters:
array
- the GammaTranlocal array to put in the pool.- Throws:
NullPointerException
- is array is null.
-
takeTranlocalArray
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:
IllegalArgumentException
- if size smaller than 0.
-
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
Puts a CallableNode in the pool.- Parameters:
node
- the CallableNode to pool.- Throws:
NullPointerException
- if node is null.
-
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
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:
NullPointerException
- if list is null.
-
takeListeners
Takes a Listeners object from the pool.- Returns:
- the Listeners object taken from the pool. or null if none is taken.
-
putListeners
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:
NullPointerException
- is listeners is null.
-
takeListenersArray
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:
IllegalArgumentException
- if minimalSize is smaller than 0.
-
putListenersArray
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:
NullPointerException
- if listenersArray is null.
-