$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Rogier van Dalen (R.C.van.Dalen_at_[hidden])
Date: 2004-04-23 04:59:36
Bronek Kozicki <brok <at> rubikon.pl> writes:
> Peter Dimov <pdimov <at> mmltd.net> wrote:
> > Nothing. The implementation of shared_ptr needs a serious redesign WRT
> > thread safety, which is planned but requires free time on my part,
> > which is currently in short supply, although I've got some ordered.
>
> Are there any chance of using reference linking instead of counter
> allocated on heap, or at least some serious optimization (ie. memory
> pool) in regard to this heap allocation?
FWIW: I have a smart pointer class similar to the boost one, in which the
ref_count class can contain the object, thus requiring one allocation only:
template <class T> class ref_count {
char data [sizeof(T)];
long strong_count;
long weak_count;
// ....
public:
// ....
};
There are two major disadvantages to this construction:
1. Quite elaborate code is needed to fake parameter forwarding.
2. The memory needed for T can be deallocated only when the memory for the
counter is (i.e. when weak_count becomes zero).
Rogier