This is usually faster than a mutex. However, you cannot just replace all mutexes with CAS. One CAS will replace one link with another in a safe manner among many threads.
If you have a compound function in which one record depends on the other read (for example), you will need a mutex to ensure atomicity.
source
share