Le 02/04/13 03:20, Michael Powell a écrit :



On Mon, Apr 1, 2013 at 6:20 PM, John Rocha <jrr@cisco.com> wrote:
Hello Michael,

*this is a pointer to the mutex that the 'lock_guard' is using. The name "this" is unfortunate since it overlaps with an object's 'this' pointer... unless your class 'mytype' is derived from a mutex....

I believe just what I'm looking for. From a previous reply, I don't "really" want to derive from lockable classes, I just want to guard this class as a potentially thread-safe operation.
 

I have added lastly some classes to Boost.Thread that could help you.

synchronized_value: uses internally a mutex to protect all the operations (1.54). It is based on the paper of Anthony Williams "Enforcing Correct Mutex Usage with Synchronized Values".

externally_locked: enforce the use of an external lock to access the object (1.53). The mutex used to protect the access canbe shared between several classes/instances. It is based on the paper of Andrei Alexandrescu "Multithreading and the C++ Type System".

HTH,
Vicente