From 10317edca59379067a6c2a3d8302f26eb9570ba6 Mon Sep 17 00:00:00 2001 From: Simon Bowden Date: Mon, 6 Jun 2022 11:34:52 +0000 Subject: Add a comment on how to achieve shared_from_this for SharedRefBase. It was time-consuming to figure out what was happening here as a newcomer. Linking to the bug where conversion was attempted for blame log convenience. I also tweaked the main description to be a bit clearer. Bug: 194905505 Change-Id: Ie5fc5a508c65c8a105a720cbef07ffdfdc6e7395 Test: comments-only --- libs/binder/ndk/include_cpp/android/binder_interface_utils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/binder/ndk/include_cpp/android/binder_interface_utils.h b/libs/binder/ndk/include_cpp/android/binder_interface_utils.h index b3bc7f449e..766df16635 100644 --- a/libs/binder/ndk/include_cpp/android/binder_interface_utils.h +++ b/libs/binder/ndk/include_cpp/android/binder_interface_utils.h @@ -43,10 +43,12 @@ namespace ndk { /** - * analog using std::shared_ptr for internally held refcount + * Binder analog to using std::shared_ptr for an internally held refcount. * * ref must be called at least one time during the lifetime of this object. The recommended way to * construct this object is with SharedRefBase::make. + * + * If you need a "this" shared reference analogous to shared_from_this, use this->ref(). */ class SharedRefBase { public: -- cgit v1.2.3-59-g8ed1b