News for hackers. Stuff that matters.
Re:Thread Safety Analysis in Clang by zvrba on Wednesday March 29, 2017 @07:00AM (#13984937)
I prefer to use language constructs to enforce correct usage where possible.

For example, if a set of values have to be synchronized by a mutex, I wrap them in a struct and http://www.boost.org/doc/libs/1_63_0/doc/html/thread/sds.htm...

If a method requires that it's called while a mutex is held, I make it explicit by declaring the function as `void f(std::unique_lock<std::mutex>&)` [requiring a reference ensures that you have to have a constructed object before function entry]. Granted, this approach doesn't associate the mutex with its data.

There are no comments on this comment yet.