[webkit-dev] Ref counting questions

Maciej Stachowiak mjs at apple.com
Wed May 22 12:38:18 PDT 2013


We could probably phase out TreeShared if we were really careful to avoid refcount thrash during tree construction/manipulation. I believe this can be done with careful use of PassRefPtr and swap() and it would likely be easier to understand if Nodes normally had a refcount of 1 instead of 0.

On May 22, 2013, at 10:41 AM, Antti Koivisto <koivisto at iki.fi> wrote:

> TreeShared is essentially an implementation detail of the DOM tree (the only other client besides Node is SVGElementInstance).  It shouldn't be used for anything else.
> 
> TreeShared keeps Nodes alive when they are part of a tree (have a parent node) even when they have zero refcount. This way nodes don't need to explicitly ref and deref their children.
> 
> 
>   antti
> 
> 
> On Wed, May 22, 2013 at 7:26 PM, Bem Jones-Bey <bjonesbe at adobe.com> wrote:
> Hey all,
> 
> I've read the document at http://www.webkit.org/coding/RefPtr.html, but I still have some questions about using RefPtrs.
> 
> The first one is listed in the "Improving this document" section of the aforementioned documentation:
>         • Perils of programming with TreeShared.
> What does that mean? What gotchas should I be aware of? (Heck, more details on any of the things in "improving this document" would be helpful, and I'll do my best to update the document with anything I learn if that's desired.)
> 
> Also, I've noticed that there's both TreeShared and RefCounted, and they seem fairly similar to my uninitiated eye. What's the difference between the two and when should one use one or the other? Also, are there other templates/classes that I should be aware of?
> 
> Thanks,
> Bem
> 
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
> 
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20130522/9eef264f/attachment.html>


More information about the webkit-dev mailing list