I have a class that has its own worker thread, and some of the member variables of the class is shared between the main thread and the worker. How can I use a mutex to lock only the member variables that are being shared?
For instance, this does not work (since the block scope is outside any function).
class Foo { public: // Some stuff private: boost::thread *m_worker; Bar m_bar_nonshared; { boost::mutex m_mutex; Bar m_bar_shared; } };