Merge "libutils: better docs for sp<>::make" am: 767f264fa4
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1663182 Change-Id: Ibb44ea12326866e455f7efc1541197fb04b77874
This commit is contained in:
commit
fb91070a83
|
@ -32,9 +32,21 @@ class sp {
|
|||
public:
|
||||
inline sp() : m_ptr(nullptr) { }
|
||||
|
||||
// TODO: switch everyone to using this over new, and make RefBase operator
|
||||
// new private to that class so that we can avoid RefBase being used with
|
||||
// other memory management mechanisms.
|
||||
// The old way of using sp<> was like this. This is bad because it relies
|
||||
// on implicit conversion to sp<>, which we would like to remove (if an
|
||||
// object is being managed some other way, this is double-ownership). We
|
||||
// want to move away from this:
|
||||
//
|
||||
// sp<Foo> foo = new Foo(...); // DO NOT DO THIS
|
||||
//
|
||||
// Instead, prefer to do this:
|
||||
//
|
||||
// sp<Foo> foo = sp<Foo>::make(...); // DO THIS
|
||||
//
|
||||
// Sometimes, in order to use this, when a constructor is marked as private,
|
||||
// you may need to add this to your class:
|
||||
//
|
||||
// friend class sp<Foo>;
|
||||
template <typename... Args>
|
||||
static inline sp<T> make(Args&&... args);
|
||||
|
||||
|
|
Loading…
Reference in New Issue