3 ms·
> For example I could make a class with a std::unique_lock<std::mutex> and a pointer to the data it protects and pass that around. This is pretty much what we
by secondcoming 6y ago
> For example I could make a class with a std::unique_lock<std::mutex> and a pointer to the data it protects and pass that around.
This is pretty much what we do in our code base, except that the class has lock(), tryLock(), etc functions that take a lambda. The functions acquire/try to acquire the mutex and then pass a reference with appropriate const-ness to the lambda.