|
Boost Users : |
Subject: Re: [Boost-users] shared_ptr and global reset
From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2009-02-26 04:11:16
2009/2/25 Alexander <gutenev_at_[hidden]>
> I am going to solve the same problem by replacing shared_ptr with a
> linked-list pointer. Each instance has pointers to two other so that all the
> instances pointing to the same object are linked in double linked loop. Size
> of such pointer is 3 times size of pointer (shared_ptr is only 2x pointer).
> This hardly can be done thread-safe without significant performance
> deradation. But it is easy to implement reset_all which changes all pointers
> that share the same ownership.
>
Common technique to reduce size of linked-list pointer is to use single
linked list instead of double linked list. Copying such pointer is liner to
the number of copies, but in cases where number of copies is low (i.e. in
most cases) it's acceptable. The biggest advantage of linked-list pointers
over shared_ptr is that they don't require additional allocation for a
counter.
Roman Perepelitsa.
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