In the classic problem of transferring money from one bank account to another, the accepted solution (I believe) is to associate a mutex with each bank account, then lock both b
Most of the solutions have a problem that data is kept public, thus one can access it without locking the lock.
There is a way to fix that, but you can't use templates and thus have to resort to macros. It is much nicer to implement in C++11 and rather then repeating the whole discussion here, I link to my implementation on: https://github.com/sveljko/lockstrap