...

/

The Two Flavors of Transactional Memory

The Two Flavors of Transactional Memory

This lesson explains synchronized and atomic blocks in transactional memory.

C++ supports transactional memory in two flavors: synchronized blocks and atomic blocks.

Synchronized & Atomic Blocks

Up to now, I only wrote about transactions. Now, I will write about synchronized blocks and atomic blocks. Both can be encapsulated in each other; specifically, synchronized blocks are not atomic blocks because they can execute transaction-unsafe. An example would be code like the output to the console which can not be undone. For this reason, synchronized blocks are often called relaxed blocks.

Synchronized Blocks

Synchronized blocks behave like they are protected by a global lock, i.e. This means that all synchronized blocks ...

Access this course and 1400+ top-rated courses and projects.