[webkit-dev] What's the difference RefPtr and OwnPtr?
Paul Hsu
pochun.hsu at gmail.com
Tue Dec 13 17:39:47 PST 2011
Very helpful.
Thanks.
Paul
On Wed, Dec 14, 2011 at 1:30 AM, Eric Seidel <eric at webkit.org> wrote:
> OwnPtr holds a pointer and calls "delete" on that pointer when it goes
> out of scope.
> Just like RefPtr, you can .release() the pointer from an OwnPtr, into
> a PassRefPtr.
> PassOwnPtr functions similarly to an OwnPtr (in that it will delete
> its pointer when it goes out of scope)
> except when you assign a PassOwnPtr to another OwnPtr it gives up its
> pointer (.release()s itself).
>
> Think of OwnPtr like RefPtr, except for singularly-owned objects
> instead of reference-counted objects.
> Think of PassOwnPtr as OwnPtr's analog to PassRefPtr.
>
> See the original files for more information:
>
>
> http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/wtf/OwnArrayPtr.h
>
> http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/wtf/OwnFastMallocPtr.h
> http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/wtf/OwnPtr.h
>
> http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/wtf/OwnPtrCommon.h
>
> http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/wtf/PassOwnArrayPtr.h
> http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/wtf/PassOwnPtr.h
> http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/wtf/PassRefPtr.h
> http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/wtf/PassTraits.h
>
> On Tue, Dec 13, 2011 at 3:18 AM, Paul Hsu <pochun.hsu at gmail.com> wrote:
> > Hi all,
> >
> > I'm a newbie in webkit development.
> >
> > I found a great article about 'RefPtr and PassRefPtr' here.
> > http://www.webkit.org/coding/RefPtr.html
> >
> > But there's no document about 'OwnPtr and PassOwnPtr'.
> >
> > I would like to ask what's the difference RefPtr and OwnPtr?
> >
> > How to use OwnPtr and PassOwnPtr?
> >
> > Need your help.
> >
> > --
> > Paul Hsu
> > pochun.hsu at gmail.com
> >
> > _______________________________________________
> > webkit-dev mailing list
> > webkit-dev at lists.webkit.org
> > http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
> >
>
--
許伯鈞(Paul Hsu)
pochun.hsu at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20111214/dd387183/attachment.html>
More information about the webkit-dev
mailing list