I have a question concerning the use of boost::lock_guard (or similar scoped locks) and using variables that should be protected by the lock in a return>
boost::lock_guard
return>
Both pieces are equivalent. In fact for case #1 - C++ compiler will create structure described in case #2. So #1 is preferable.