Instead of using locks, we instead have transactions on memory. This is kind of like database transactions. Memory operations either success, or get rolled back to retry later.

Pros and Cons

Pros:

  • No need to worry about deadlocks or lock granularity
  • Just a group of code that is operationally atomic
  • This is up to the implementer to make sure that things are actually atomic Cons:
  • Some things cannot be rolled back (write to the screen)
  • Limited transaction size
  • Nested transactions?

Warning

Being able to rollback does not protect against dataraces.

Related