org.multiverse.stms.alpha.mixins
Class ThreadUnsafeTxObjectMixin

java.lang.Object
  extended by org.multiverse.stms.alpha.mixins.ThreadUnsafeTxObjectMixin
All Implemented Interfaces:
org.multiverse.api.commitlock.CommitLock, org.multiverse.MultiverseConstants, AlphaTransactionalObject

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

A threadunsafe tx object mixin that can be used for benchmarking purposes if you want to see what the overhead is caused by cas/volatile read/volatile write operations.

Can't be used in a multithreaded program.


Field Summary
 
Fields inherited from interface org.multiverse.MultiverseConstants
___SANITY_CHECKS_ENABLED
 
Constructor Summary
ThreadUnsafeTxObjectMixin()
           
 
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.
 AlphaTranlocal ___openUnconstructed()
          Creates a fresh AlphaTranlocal.
 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
 

Constructor Detail

ThreadUnsafeTxObjectMixin

public ThreadUnsafeTxObjectMixin()
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.

___getListeners

public org.multiverse.api.Listeners ___getListeners()

___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

___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

___openUnconstructed

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

Specified by:
___openUnconstructed in interface AlphaTransactionalObject
Returns:
the created AlphaTranlocal.

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

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