...
/Single Threaded Summation: Protection with Locks
Single Threaded Summation: Protection with Locks
This lesson explains the solution for calculating the sum of a vector problem using locks in C++.
We'll cover the following...
If I protect access to the summation variable with a lock, I will get the answers to two questions.
- How expensive is the synchronization of a lock without contention?
- How fast can a lock be in the optimal case?
I can draw an interesting conclusion from question 2. If there is contention on a lock, the access time will decrease. That being said, I will only show the application of std:lock_guard
.
Access this course and 1400+ top-rated courses and projects.