Microsoft has made available a first beta version of an experimental version of .NET 4.0, called .NET Framework 4.0 Beta 1 Enabled for Software Transactional Memory v1.0. Since that is quite a long name, the short one is STM.NET. This is a special version of .NET 4.0 that enables software transactional memory for C#. It allows programmers to demarcate regions of code as operating in an atomic, isolated transaction from other code running concurrently. The means to do this is a delegate called Atomic.Do, or try-catch blocks. Might be that in the future an ‘atomic’ block will be added to the language(s).
This first version of the framework, also comes with additional tools:
- tooling (debugging, ETW tracing)
- lock interoperability
- interoperability with traditional transactions
- annotations (how methods run in transactions, suppressed transactions on methods, etc.)
- static and dynamic checking of annotations
On the other hand there are some limitations:
- only works for C# for now
- cannot be installed on a machine with VS 2010, nor the opposite
- there is only a 32-bit version
More information about it can be found at the STM team blog or MSDN DevLabs.
A lightweight C# STM alternative
https://github.com/SepiaGroup/STMNet