|
Boost Users : |
Subject: Re: [Boost-users] Good lock_guard<mytype> example
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-04-02 01:32:05
Le 02/04/13 03:20, Michael Powell a écrit :
>
>
>
> On Mon, Apr 1, 2013 at 6:20 PM, John Rocha <jrr_at_[hidden]
> <mailto:jrr_at_[hidden]>> 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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net