[webkit-dev] What's the difference RefPtr and OwnPtr?
Ryosuke Niwa
rniwa at webkit.org
Tue Dec 13 17:44:18 PST 2011
I've filed https://bugs.webkit.org/show_bug.cgi?id=74470 for the future
reference.
- Ryosuke
On Tue, Dec 13, 2011 at 5:39 PM, Paul Hsu <pochun.hsu at gmail.com> wrote:
> 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
>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20111213/cca2e4f4/attachment.html>
More information about the webkit-dev
mailing list