org.multiverse.stms.alpha
Interface AlphaTransactionalObject

All Superinterfaces:
org.multiverse.api.commitlock.CommitLock
All Known Implementing Classes:
AlphaProgrammaticLong, AlphaProgrammaticReference, DefaultTxObjectMixin, FastTxObjectMixin, ThreadUnsafeTxObjectMixin

public interface AlphaTransactionalObject
extends org.multiverse.api.commitlock.CommitLock

This is the interface placed on the POJO's that want to participate in the alpha STM.

In most cases a user of the library is not going to worry bout this interface. Instrumentation is going to do all that work based on annotations.

Author:
Peter Veentjer.

Method Summary
 AlphaTranlocal ___load()
          Loads the most recently committed AlphaTranlocal.
 AlphaTranlocal ___load(long readVersion)
          Loads a readonly AlphaTranlocal with a version equal or smaller than readVersion.
 AlphaTranlocal ___openForCommutingOperation()
          Opens this AlphaTransactionalObject for a commuting operation.
 AlphaTranlocal ___openUnconstructed()
          Creates a fresh AlphaTranlocal.
 RegisterRetryListenerResult ___registerRetryListener(org.multiverse.api.latches.Latch listener, long wakeupVersion)
          Registers a listener for retrying (the condition variable version for STM's).
 void ___storeInitial(AlphaTranlocal tranlocal, long writeVersion)
          The store that is executed after a transactional object is constructed.
 org.multiverse.api.Listeners ___storeUpdate(AlphaTranlocal tranlocal, long writeVersion, boolean releaseLock)
          Stores the the content and releases the lock.
 
Methods inherited from interface org.multiverse.api.commitlock.CommitLock
___getLockOwner, ___releaseLock, ___tryLock
 

Method Detail

___load

AlphaTranlocal ___load()
Loads the most recently committed AlphaTranlocal. Call never fails. Value could be stale as soon as it is retrieved. If no commits have been made, null is returned.

Returns:
the most recently written AlphaTranlocal.

___load

AlphaTranlocal ___load(long readVersion)
Loads a readonly AlphaTranlocal with a version equal or smaller than readVersion. It is very important for the implementation to not to return a too old version. If this happens, the system could start to suffer from lost updates (not seeing changes you should have seen).

Parameters:
readVersion - the version of the Tranlocal to read.
Returns:
the loaded Tranlocal. If nothing is committed, null is returned.
Throws:
org.multiverse.api.exceptions.ReadConflict - if the system wasn't able to load the Tranlocal.

___storeUpdate

org.multiverse.api.Listeners ___storeUpdate(AlphaTranlocal tranlocal,
                                            long writeVersion,
                                            boolean releaseLock)
Stores the the content and releases the lock.

It is important that this call only is made when the lock already was acquired.

This call will not fail (unless something is terribly wrong)

Parameters:
tranlocal - the Tranlocal to storeAndReleaseLock.
writeVersion - the version to storeAndReleaseLock the Tranlocal with.
releaseLock - is the lock should be released immediately after the write. This functionality is needed for the quickReleaseWriteLocks optimization.
Returns:
the Listeners to wake up. Could be null if there are no listeners to wake up.

___storeInitial

void ___storeInitial(AlphaTranlocal tranlocal,
                     long writeVersion)
The store that is executed after a transactional object is constructed. Once committed, the ___storeUpdate(AlphaTranlocal, long, boolean) needs to be used.

Parameters:
tranlocal - the tranlocal to store.
writeVersion - the version of the write.

___openUnconstructed

AlphaTranlocal ___openUnconstructed()
Creates a fresh AlphaTranlocal. This can be used when a write on a tranlocal needs to be done, but no tranlocal has been created yet (so should be created in the constructor).

Returns:
the created AlphaTranlocal.

___openForCommutingOperation

AlphaTranlocal ___openForCommutingOperation()
Opens this AlphaTransactionalObject for a commuting operation.

Returns:
the AlphaTranlocal opened

___registerRetryListener

RegisterRetryListenerResult ___registerRetryListener(org.multiverse.api.latches.Latch listener,
                                                     long wakeupVersion)
Registers a listener for retrying (the condition variable version for STM's). The Latch is a concurrency structure that can be used to let a thread (transaction) wait for a specific event. In this case we use it to notify the Transaction that the desired update has taken place.

Parameters:
listener - the Latch to registerLifecycleListener.
wakeupVersion - the minimum version to wake up for.
Returns:
true if the listener was registered on a committed object, false otherwise.


Copyright © 2008-2010 Multiverse. All Rights Reserved.