Add a basis software transactional system #81
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The general idea is that all accesses to objects and arrays are mediated via
Change
objects. These keep a copy of the initial state, and a working copy onwhich the transactions perform their accesses. On commit, we simply compare the
initial state with the publicly visible objects, if any change (conflict) is
seen the transaction retries. If no conflict was determined, the new state is
copied into the publicly visible object.
Transactions always succeed, this implementation automatically retries.
The initial creation of a
Change
object accesses the public object whileholding its lock. Similarly, on writing back changes, the lock is acquired.
Transaction commits are globally sequentialized on a single lock.
Method and blocks executed inside a transaction execute an
atomic
variant oftheir method body. All invocable used in the transactional context, i.e.,
within a
atomic: [...]
execution are split from the normal methods, andmarked as
isAtomic
. This flag allows to insert the necessary nodes to ensurethat a transaction works on working copies private to the transaction.
To avoid issues with class identity, the slots storing lazily allocated class
objects are ignored when comparing and updating objects.
Inspired by: Transactional Memory for Smalltalk
L. Renggli, and O. Nierstrasz. In Proc. of ICDL, 2007.
DOI: 10.1145/1352678.1352692