Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Timestamp based STM in Scala


latest commit 367194b719
Flavio W. Brasil authored March 02, 2014
Octocat-spinner-32 project 1.5-M4 March 02, 2014
Octocat-spinner-32 src refined transaction types / allow reads without transaction February 09, 2014
Octocat-spinner-32 .gitignore . December 30, 2011
Octocat-spinner-32 .travis.yml travis build February 08, 2014
Octocat-spinner-32 LICENSE-LGPL Changing to LGPL June 07, 2011
Octocat-spinner-32 Fix typo. December 03, 2012

Build Status


RadonSTM is a timestamp based Software Transaction Memory (STM) implementation in Scala. The main framework objective is providing a simple and flexible way to deal with concurrency. STM is a wide known solution implemented in many languages.

This project was initially based on Daniel Spiewak STM implementation and grew up focused on providing the basis for Activate Persistence Framework.

Radon has features like propagation control, nested transactions and ref destroying.



val radonStm = "net.fwbrasil" %% "radon-stm" % "0.0.1"
val fwbrasil = "" at ""




Getting Started

Put the radon jar in the classpath and create a Radon context:

object TestRadonContext extends RadonContext

Import the context object for the classes where you want to use Radon:

import TestRadonContext._

Concurrency control is achieved by using Ref objects in transactional blocks like:

transactional {
    val ref = new Ref(100)
    ref :== 300

To set a ref value use set or :==, and to get a ref value use get or the unary ! method.

Important: Make sure to use immutable values inside Ref.

You can use ref objects on many threads without caring about concurrency. RadonSTM detects conflicts and retries the transaction if it is needed. Transaction is hold on a thread local while it is active, so you can have code under a transaction without declaring the "transactional" keyword.

Typically transactional blocks are controlled by the framework. However, it's possible to control a transaction as follows:

val transaction = new Transaction
transactional(transaction) {
    val ref = new Ref(100)

You can define a transaction propagation:

transactional {
    val ref = new Ref(100)
    transactional(mandatory) {
        ref := 200

Nested transactions are a type of propagation:

transactional {
    val ref = new Ref(100)
    transactional(nested) {
        ref := 200

The available propagations are based on EJB propagations:

  • required
  • requiresNew
  • mandatory
  • notSupported
  • supports
  • never
  • nested

It is possible to destroy a Ref and, after that, it can't be read or written:

transactional {
    val ref = new Ref(100)

Take a look in  Sleeping Barber Spec.


All code in this repository is licensed under the LGPL. See the LICENSE-LGPL file for more details.

Something went wrong with that request. Please try again.