Bug 158596 - Introduce WTF::UniqueRef
Summary: Introduce WTF::UniqueRef
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-09 18:51 PDT by Alex Christensen
Modified: 2016-06-10 14:24 PDT (History)
5 users (show)

See Also:


Attachments
Patch (24.84 KB, patch)
2016-06-09 19:10 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (24.96 KB, patch)
2016-06-09 19:16 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (25.13 KB, patch)
2016-06-09 20:20 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (25.46 KB, patch)
2016-06-09 22:09 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (27.02 KB, patch)
2016-06-09 22:21 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (27.06 KB, patch)
2016-06-09 23:26 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (27.45 KB, patch)
2016-06-09 23:55 PDT, Alex Christensen
beidson: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2016-06-09 18:51:51 PDT
Introduce WTF::Unique
Comment 1 Alex Christensen 2016-06-09 19:10:28 PDT
Created attachment 280974 [details]
Patch
Comment 2 Alex Christensen 2016-06-09 19:16:21 PDT
Created attachment 280975 [details]
Patch
Comment 3 Alex Christensen 2016-06-09 20:20:34 PDT
Created attachment 280983 [details]
Patch
Comment 4 Darin Adler 2016-06-09 20:21:22 PDT
I like the idea of this class, but I’m not sure I’m comfortable with the name Unique.
Comment 5 Darin Adler 2016-06-09 20:21:41 PDT
Maybe UniqueRef by analogy with unique_ptr.
Comment 6 Alex Christensen 2016-06-09 22:09:09 PDT
Created attachment 280990 [details]
Patch
Comment 7 Alex Christensen 2016-06-09 22:21:56 PDT
Created attachment 280994 [details]
Patch
Comment 8 Alex Christensen 2016-06-09 23:26:05 PDT
Created attachment 280997 [details]
Patch
Comment 9 Alex Christensen 2016-06-09 23:55:43 PDT
Created attachment 280999 [details]
Patch
Comment 10 Michael Catanzaro 2016-06-10 05:36:18 PDT
Comment on attachment 280999 [details]
Patch

I see the point: you have to use something like std::unique_ptr here, and having a type to indicate it can never be null seems useful. I just wonder if the actual benefit would be worth the cost of having one more type of Ref to learn and understand. Probably; converting pointer member variables to refs elsewhere in the code has had big readability benefits. Shame there's no standard solution for this.

Agreed with Darin that the name is not good, a "unique ref" sounds like something that shouldn't be refcounted. It's hard to name though... "NonintrusiveRef" is not great, but it's the best I can think of. "NonnullUniquePtr" is awkward but clear. Alternatively we could try to think of a name that indicates its purpose for holding values of polymorphic type.
Comment 11 Alex Christensen 2016-06-10 14:24:41 PDT
http://trac.webkit.org/changeset/201941