async-stm is an implementation of Software Transactional Memory.
It was originally inspired by rust-stm,
but does things sligly differently, in a more traditional fashion.
It was also extended in the following ways:
- Made
atomicallyasynchronous, so STM operations can be used withtokiowithout blocking a full thread. - Added the ability to
aborta transaction with an error, which the caller has to handle. - The transaction is passed around in a thread-local variable, for a simplified
TVarAPI. - Reading a
TVarreturns anArc, so cloning can be delayed until we have to modify the result. - Added the option to pass in an auxiliary transaction that gets committed or rolled back together with the STM transaction, and can also cause a retry if it detects some conflict of its own. This is a potential way to have a hybrid persistent STM solution.
- Added some optional queue implementations based on Simon Marlow's book, Parallel and Concurrent Programming in Haskell.
Please look at the tests for example usage.
Install the following to be be able to build the project:
curl https://sh.rustup.rs -sSf | sh
rustup toolchain install nightly
rustup default stable
rustup updateThere are benchmarks included to help compare the tradeoffs between the different queue implementations.
cargo +nightly bench "bench" --all-features- https://www.microsoft.com/en-us/research/publication/beautiful-concurrency/
- https://bartoszmilewski.com/2010/09/11/beyond-locks-software-transactional-memory/
This project is licensed under the MIT license.