Package org.multiverse.stms.gamma
Class Listeners
java.lang.Object
org.multiverse.stms.gamma.Listeners
A Listeners object contains all the Latches of blockingAllowed transactions that listen to a write on a
transactional object. Essentially it is a single linked list.
This is an 'immutable' class. As long as it is registered to a transactional object, it should not be mutated.
But as soon as it is removed as listener, only a single thread has access to this Listeners object. This means
that it can be pooled.
Setting the Listeners and removing the it should provide the happens before relation so that all changes made
to the Listener before it is getAndSet, are visible when it is removed.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
openAll
(GammaObjectPool pool) Opens all latches.static void
openAll
(Listeners[] listenersArray, GammaObjectPool pool) Opens all the listeners.void
Prepares this Listeners object for pooling.
-
Field Details
-
next
-
listener
-
listenerEra
public long listenerEra
-
-
Constructor Details
-
Listeners
public Listeners()
-
-
Method Details
-
prepareForPooling
public void prepareForPooling()Prepares this Listeners object for pooling. This is done by:- setting the next to null
- setting the listener to null
- setting the listenerEra to Long.MIN_VALUE
-
openAll
Opens all latches. All Listeners are put in the pool. The Latches are not put in the pool since no guarantee can be given that the Latch is still registered on a different transactional object. This call should only be done by the transaction that removed the listeners from the transactional object. So it is not threadsafe,- Parameters:
pool
- the GammaObjectPool to store the discarded Listeners in.
-
openAll
Opens all the listeners. As soon as in the array a null element is found, it signals the end of the list of listeners. This makes is possible to place an array that is larger than the actual number of writes. The call safely can be made with a null listenersArray. In that case the call is ignored.- Parameters:
listenersArray
- the array of Listeners to notify.pool
- the GammaObjectPool to pool the Listeners and the array containing the listeners.
-