public interface Stm
TxnObject
: the structure where state and identity are separated and where state change
is coordinated through a transaction. An example of the TxnObject is the TxnRef
,
but it could just as easily by a more complex transactional datastructure that is enhanced by instrumentation.
Txn
: responsible for making sure that all changes on transactionalobjects are atomic, isolated and consistent.
TxnExecutor
: responsible for starting/committing/aborting/retrying transactions. The TxnExecutor executes an
TxnCallable
(there are different tastes for return values). The TxnCallable contains
the logic that needs to be executed atomic, isolated and consistent.
The Stm interface provides a mechanism to separate the contract from the implementation. So it is possible to change the Stm implementation without changing the code that uses it. The idea is that for example a TL2 (MVCC) based implementation can be replaced by a Sky-STM or a lock based STM. Of course every Stm implementation will have its strong and weak spots.
All functionality like TxnExecutors, Refs, Txn etc can be customized by providing a custom implementation of the factory/builder interfaces:
TxnRefFactoryBuilder
a builder for creating TxnRefFactory
TxnFactoryBuilder
a builder for creating an TxnExecutor
/Txn
.
TxnCollectionsFactory
a factory for creating transactional collectionsIt is important that an TxnObject only is used within a single Stm. If it is 'shared' between different stm instances, isolation problems could happen. This can be caused by the fact that different stm instances probably use different clocks or completely different mechanisms for preventing isolation problems. It depends on the implementation if any checking is done (the GammaStm does check if there is a conflict).
Modifier and Type | Method and Description |
---|---|
TxnRefFactory |
getDefaultRefFactory()
Returns the default
TxnRefFactory that can be used for easy and cheap access to a reference factory
instead of setting one up through the TxnRefFactoryBuilder . |
TxnCollectionsFactory |
getDefaultTxnCollectionFactory()
Gets the default
TxnCollectionsFactory . |
TxnExecutor |
getDefaultTxnExecutor()
Returns the default
TxnExecutor that is useful for testing/experimentation purposes. |
TxnRefFactoryBuilder |
getTxRefFactoryBuilder()
Gets the
TxnRefFactoryBuilder . |
Txn |
newDefaultTxn()
Starts a default Txn that is useful for testing/experimentation purposes.
|
OrElseBlock |
newOrElseBlock()
Creates an OrElseBlock.
|
TxnFactoryBuilder |
newTxnFactoryBuilder()
Gets the
TxnFactoryBuilder that needs to be used to execute a Txn created by this Stm. |
TxnFactoryBuilder newTxnFactoryBuilder()
TxnFactoryBuilder
that needs to be used to execute a Txn
created by this Stm.
See the TxnFactoryBuilder
for more info. The TxnFactoryBuilder also is responsible for creating
the TxnExecutor since the Txn and TxnExecutor can be tightly coupled.Txn newDefaultTxn()
newTxnFactoryBuilder()
for something more configurable.
In mose cases this is not the method you want to use to manage transactions.
Transactions returned by this method are not speculative.
TxnExecutor getDefaultTxnExecutor()
TxnExecutor
that is useful for testing/experimentation purposes.
This method is purely for easy to use access, but it doesn't provide any configuration options.
See the newTxnFactoryBuilder()
for something more configurable.
Transactions used in this Block are not speculative.
OrElseBlock newOrElseBlock()
TxnRefFactory getDefaultRefFactory()
TxnRefFactory
that can be used for easy and cheap access to a reference factory
instead of setting one up through the TxnRefFactoryBuilder
.TxnRefFactoryBuilder getTxRefFactoryBuilder()
TxnRefFactoryBuilder
.TxnCollectionsFactory getDefaultTxnCollectionFactory()
TxnCollectionsFactory
.TxnCollectionsFactory
.Copyright © 2020. All rights reserved.