org.multiverse.stms.alpha.mixins
Class DefaultTxObjectMixin

java.lang.Object
  extended by org.multiverse.stms.alpha.mixins.DefaultTxObjectMixin
All Implemented Interfaces:
org.multiverse.api.commitlock.CommitLock, org.multiverse.MultiverseConstants, AlphaTransactionalObject
Direct Known Subclasses:
AlphaProgrammaticLong, AlphaProgrammaticReference

public abstract class DefaultTxObjectMixin
extends Object
implements AlphaTransactionalObject, org.multiverse.MultiverseConstants

AlphaTransactionalObject implementation that also can be used to transplant methods from during instrumentation. This implementation supports listeners.

It is important that the constructor doesn't contain any donorMethod because the constructor code is not copied when this class is 'mixed' in. In the future perhaps this is fixed when there needs to be a constructor. So you are warned.

Author:
Peter Veentjer

Field Summary
 
Fields inherited from interface org.multiverse.MultiverseConstants
___SANITY_CHECKS_ENABLED
 
Constructor Summary
DefaultTxObjectMixin()
           
 
Method Summary
 org.multiverse.api.Listeners ___getListeners()
           
 org.multiverse.api.Transaction ___getLockOwner()
           
 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.
 RegisterRetryListenerResult ___registerRetryListener(org.multiverse.api.latches.Latch listener, long minimumWakeupVersion)
          Registers a listener for retrying (the condition variable version for STM's).
 void ___releaseLock(org.multiverse.api.Transaction expectedLockOwner)
           
 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.
 boolean ___tryLock(org.multiverse.api.Transaction lockOwner)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.multiverse.stms.alpha.AlphaTransactionalObject
___openUnconstructed
 

Constructor Detail

DefaultTxObjectMixin

public DefaultTxObjectMixin()
Method Detail

___load

public AlphaTranlocal ___load()
Description copied from interface: AlphaTransactionalObject
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.

Specified by:
___load in interface AlphaTransactionalObject
Returns:
the most recently written AlphaTranlocal.

___load

public AlphaTranlocal ___load(long readVersion)
Description copied from interface: AlphaTransactionalObject
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).

Specified by:
___load in interface AlphaTransactionalObject
Parameters:
readVersion - the version of the Tranlocal to read.
Returns:
the loaded Tranlocal. If nothing is committed, null is returned.

___openForCommutingOperation

public AlphaTranlocal ___openForCommutingOperation()
Description copied from interface: AlphaTransactionalObject
Opens this AlphaTransactionalObject for a commuting operation.

Specified by:
___openForCommutingOperation in interface AlphaTransactionalObject
Returns:
the AlphaTranlocal opened

___storeUpdate

public org.multiverse.api.Listeners ___storeUpdate(AlphaTranlocal tranlocal,
                                                   long writeVersion,
                                                   boolean releaseLock)
Description copied from interface: AlphaTransactionalObject
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)

Specified by:
___storeUpdate in interface AlphaTransactionalObject
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

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

Specified by:
___storeInitial in interface AlphaTransactionalObject
Parameters:
tranlocal - the tranlocal to store.
writeVersion - the version of the write.

___getLockOwner

public org.multiverse.api.Transaction ___getLockOwner()
Specified by:
___getLockOwner in interface org.multiverse.api.commitlock.CommitLock

___tryLock

public boolean ___tryLock(org.multiverse.api.Transaction lockOwner)
Specified by:
___tryLock in interface org.multiverse.api.commitlock.CommitLock

___releaseLock

public void ___releaseLock(org.multiverse.api.Transaction expectedLockOwner)
Specified by:
___releaseLock in interface org.multiverse.api.commitlock.CommitLock

___getListeners

public org.multiverse.api.Listeners ___getListeners()

___registerRetryListener

public RegisterRetryListenerResult ___registerRetryListener(org.multiverse.api.latches.Latch listener,
                                                            long minimumWakeupVersion)
Description copied from interface: AlphaTransactionalObject
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.

Specified by:
___registerRetryListener in interface AlphaTransactionalObject
Parameters:
listener - the Latch to registerLifecycleListener.
minimumWakeupVersion - 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.