This is an academic project. It's not optimized in any way to be used in real life, resource demanding escenarios (it should be useful as a base to achieve that goal though).
Gems: parser, unparser.
Tested with:
- MRI 2.1 / 2.2 / 2.3
- Rubinius 3.14
First, require ruby_core_ext/proc.rb to extend Proc class with the 'atomic' method.
Send the 'atomic' message to a Proc you want to execute atomically.
To execute atomically and handle a commit conflict use 'atomic_if_conflict &a_block'.
Also, 'atomic_retry' is available for automatic retry the transaction on commit conflict.
See the examples
directory for scripts that demonstrate how to use this library.
Use 'transfer.call' instead of 'transfer.atomic_retry' to execute non-atomically.
- Cannot handle multiple procs defined in a single line (separated by ';').
- Methods or procs defined by metaprogramming means (like eval) cannot be executed inside a transaction out of the box (must implement atomic variant manually).
- Nested transactions are not supported.
- For the moment, atomicity is only guaranteed for instance variables (including class instance variables but not class variables).
- Performance is poor, especially in Rubinius.