Boost logo

Boost :

From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2007-08-25 13:38:32

Frank Mori Hess wrote:
> On Friday 24 August 2007 09:57, Phil Endecott wrote:
>> In the same vein, I have sometimes considered making the use of these
>> primitives even more idiot-proof by bundling together a mutex,
>> condition and the variable that they protect:
>> template <typename T>
>> class locked {
>> mutex m;
>> condition c;
>> T v;
>> };
> You might be interested in this paper, which describes a nice way of
> wrapping an object so a mutex in the wrapper is always locked when
> accessing the object's member functions.

Hi Frank,

Thanks; yes, I think this sort of thing would also be a useful addition
to Boost. The syntax that I presented had the advantage that


can have a single lock around both operations, while Bjarne's wrapper
would lock and unlock for each one. Also, I'm not sure whether his
could be extended to offer read locks for some operations and write
locks for others.

I'll currently hacking an old file that has some ad-hoc mutexes and
conditions in it. Perhaps I'll see if I can factor-out a generic
wrapper from it.



Boost list run by bdawes at, gregod at, cpdaniel at, john at