Boost logo

Boost :

From: Gregory Colvin (gregory.colvin_at_[hidden])
Date: 2003-05-30 14:06:40


On Friday, May 30, 2003, at 12:38 America/Denver, Chuck Messenger wrote:

> Gregory Colvin wrote:
>> Thanks, but your description of cyclic_ptr is pretty far off the mark.
>
> Sorry -- hopefully you'll forgive my ignorance. I'm just throwing out
> what I understand to be the case, in the hopes that someone (such as
> yourself) would set me straight...
>
>> It does not maintain a global map, and copying cyclic_ptr cost the
>> same
>> as copying shared_ptr.
>
> OK, I'll have to review the old messages again. I thought someone had
> said cyclic_ptr used a global map. Sorry. I suppose better yet would
> be for me to study your actual *code*...

Larry's analysis gives a better explanation than I could.

> Do you do a raw scan of memory, like sp_collector, then? (i.e. not
> perfect discovery)

No. The self-assignment trick is precise, unless it is foiled by a
user-written operator=.

>> The special assignment mode is used only during
>> the mark phase of a collection, and costs more or less the same as any
>> other discovery method.
>
> Suppose I have the structure:
>
> struct Image {
> char huge_image[ONE_ZILLION];
> cyclic_ptr<whatever> ptr;
> };
>
> As I understand it, in order to discover 'ptr', you'd invoke
> operator=() on each Image structure you came to. Correct, or
> incorrect?

Correct. So it would be smart to write an operator= for Image that
avoids copying huge_image to itself. And it would best if the
uber-pointer used a less intrusive discovery method. I think
sp_collector is on the right track, if it could be made precise.


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