Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-01-29 07:34:24


From: "David B. Held" <dheld_at_[hidden]>
> "Beman Dawes" <bdawes_at_[hidden]> wrote in message
> news:4.3.2.7.2.20030127213406.022872f8_at_mailhost.esva.net...
> > [...]
> > For a shared-ownership smart pointer with weak_ptr support, I expect
> > some people will say that mandates a refcounted rather than reflinked
> > implementation. I don't think that is true, but it may make a reflinked
> > implementation less attractive. What's your opinion on that?
>
> I was looking through Peter's GC code, and I see that he builds a
> map of pointers. I was wondering if a ref-linked implementation
> would make the scan process faster.

Some GCSP implementations do use linked pointers... although they typically
keep one big list. This allows them to know precisely where all smart
pointers are.

The MT downside is that every smart pointer operation needs to grab a global
lock. Counted pointers have a per-object mutex. (On a straightforward
implementation; synchronization experts may be able to avoid the lock using
atomic intructions in one or both cases.)

> You could maintain a map of
> pointers that would constitute your root set? Then instead of
> scanning raw memory, just scan the ref-links? Maybe that's what
> Andrei was referring to by the "shared global map approach".

Andrei was probably referring to my "design notes" about raw to smart
conversions; one solution is to keep a global object pointer to count
pointer map. See for example

http://web.onetel.net.uk/~anthony_w/cplusplus/genericptr.pdf
http://web.onetel.net.uk/~anthony_w/cplusplus/genericptr.zip

from

http://cplusplus.anthonyw.cjb.net/articles.html


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