Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-02-27 08:08:08


Sorry for the belated response.

Jeffrey Yasskin:

> On Jan 18, 2008 10:34 AM, Peter Dimov <pdimov_at_[hidden]> wrote:
...

> > I (and many others) will be very, very interested in your
> > implementation,
> > doubly so if you implement it using the interface proposed in
> >
> > http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2007/n2297.html#atomic
>
> Thanks for the support! I currently plan to extrapolate from the
> design of atomic<T> from N2427 instead of adding operations to
> shared_ptr itself. The requirement that "A program is allowed to
> access the same shared_ptr instance concurrently from multiple threads
> if the access is done exclusively via the member functions in this
> section." implies that instances accessed through those three methods
> are logically a separate type from instances accessed through other
> methods.

There are use cases in which you really do want to access the same variable
in both atomic and non-atomic ways. Something like:

rwm_.rdlock();
// use atomic accesses on px
rwm_.unlock();

//...

rwm_.wrlock();
// use non-atomic accesses on px, we're exclusive
rwm_.unlock();


Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk