Hi !
I've
created two simples classes that helped me avoid data races
when sharing objects among threads.
The idea is to
declare objects that need for synchronization as
Synchronized<T>, which holds a T and a mutex. To use
the T, a Get function has to be called that returns a proxy,
which holds a pointer to the T and a scoped lock on the
mutex. The proxy defines operator-> and operator* to give
access to the T. To have acces to the T, one has to create
the proxy. As long as the proxy exists, the mutex associated
with the T is locked, effectively preventing use by other
threads.
I find the scheme
general purpose enough to fit the Atomic lib, or perhaps
Thread.
Please
manifest yourselves if there is any interest in such device.