Allow RefPtr to operate on arbitrary pointers with RefPtrTraits

RESOLVED FIXED in Firefox 47

Status

()

defect
RESOLVED FIXED
4 years ago
3 years ago

People

(Reporter: bholley, Assigned: bholley)

Tracking

unspecified
mozilla47
Points:
---

Firefox Tracking Flags

(firefox47 fixed)

Details

Attachments

(2 attachments)

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

I have working patches, uploading momentarily.
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+
You need to log in before you can comment on or make changes to this bug.