Allow RefPtr to operate on arbitrary pointers with RefPtrTraits

RESOLVED FIXED in Firefox 47

Status

()

RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: bholley, Assigned: bholley)

Tracking

unspecified
mozilla47
Points:
---

Firefox Tracking Flags

(firefox47 fixed)

Details

Attachments

(2 attachments)

(Assignee)

Description

3 years ago
Per discussion on IRC. This will be useful for our opaque pointers to reference-counted Servo types.

I have working patches, uploading momentarily.
(Assignee)

Comment 1

3 years ago
Created attachment 8719993 [details] [diff] [review]
Part 1 - Rename the existing AddRefTraits to ConstRemovingRefPtrTraits. v1
Attachment #8719993 - Flags: review?(nfroyd)
(Assignee)

Comment 2

3 years ago
Created attachment 8719994 [details] [diff] [review]
Part 2 - Extract the AddRef/Release calls into a non-inner helper trait. v1
Attachment #8719994 - Flags: review?(nfroyd)
Attachment #8719993 - Flags: review?(nfroyd) → review+
Comment on attachment 8719994 [details] [diff] [review]
Part 2 - Extract the AddRef/Release calls into a non-inner helper trait. v1

Review of attachment 8719994 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with some additional documentation.

::: mfbt/RefPtr.h
@@ +20,5 @@
>  namespace mozilla {
>  template<class T> class OwningNonNull;
> +
> +template<class U>
> +struct RefPtrTraits

Could you please write a bit of documentation here?  Seomthing about how the canonical way to refcount with RefPtr is to use AddRef and Release methods, but if you have a pointer type that has differently-named methods, you can use specializations of RefPtrTraits to call those methods instead?

Please also document that U should not be a |const|-qualified type, or add a static_assert to verify !IsConst<U>::value.
Attachment #8719994 - Flags: review?(nfroyd) → review+

Comment 7

3 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/c9431b91f570
https://hg.mozilla.org/mozilla-central/rev/5039eb1fa76c
https://hg.mozilla.org/mozilla-central/rev/b8231765b22c
Status: NEW → RESOLVED
Last Resolved: 3 years ago
status-firefox47: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
You need to log in before you can comment on or make changes to this bug.