Boost logo

Boost :

From: Emil Dotchevski (emil_at_[hidden])
Date: 2008-03-10 18:27:16


On Mon, Mar 10, 2008 at 3:18 PM, Mathias Gaunard
<mathias.gaunard_at_[hidden]> wrote:
> I see that shared_ptr is quite costly in multithreaded environments
> cause it would need DCAS, and thus uses a spinlock in cases where it is
> not available.

If you pass shared_ptr objects by const &, the refcount doesn't need
to be updated.

Move semantics would make things like inserting into
std::vector<shared_ptr<foo> > not update the refcount too. Until then,
in most cases you can use std::deque<shared_ptr<foo> > instead.

Do you have specific use case which demonstrates that shared_ptr's
refcounting is the bottleneck? If you do, you can post it here for
discussion and/or a possible fix.

-- 
Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode

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