A thread has the following control flow:
mutex.lock()
if (condition) {
// do synced things
mutex.unlock();
// do parallel things
} else {
// do other synced things
mutex.unlock();
// do other parallel things
}
Note how the four do
parts all execute different things.
How do I replace direct calls to lock and unlock into using std::lock_guard
instead?