Loading libs/binder/ndk/include_ndk/android/binder_auto_utils.h +7 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ #include <android/binder_parcel.h> #include <android/binder_status.h> #include <assert.h> #ifdef __cplusplus #include <cstddef> Loading Loading @@ -76,7 +78,11 @@ public: * Takes ownership of one strong refcount of binder */ void set(AIBinder* binder) { if (mBinder != nullptr) AIBinder_decStrong(mBinder); AIBinder* old = *const_cast<AIBinder* volatile*>(&mBinder); if (old != nullptr) AIBinder_decStrong(old); if (old != *const_cast<AIBinder* volatile*>(&mBinder)) { __assert(__FILE__, __LINE__, "Race detected."); } mBinder = binder; } Loading libs/binder/ndk/include_ndk/android/binder_interface_utils.h +10 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ #include <android/binder_auto_utils.h> #include <android/binder_ibinder.h> #include <assert.h> #ifdef __cplusplus #include <memory> Loading @@ -39,11 +41,18 @@ namespace ndk { /** * analog using std::shared_ptr for 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. */ class SharedRefBase { public: SharedRefBase() {} virtual ~SharedRefBase() {} virtual ~SharedRefBase() { std::call_once(mFlagThis, [&]() { __assert(__FILE__, __LINE__, "SharedRefBase: no ref created during lifetime"); }); } /** * A shared_ptr must be held to this object when this is called. This must be called once during Loading Loading
libs/binder/ndk/include_ndk/android/binder_auto_utils.h +7 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ #include <android/binder_parcel.h> #include <android/binder_status.h> #include <assert.h> #ifdef __cplusplus #include <cstddef> Loading Loading @@ -76,7 +78,11 @@ public: * Takes ownership of one strong refcount of binder */ void set(AIBinder* binder) { if (mBinder != nullptr) AIBinder_decStrong(mBinder); AIBinder* old = *const_cast<AIBinder* volatile*>(&mBinder); if (old != nullptr) AIBinder_decStrong(old); if (old != *const_cast<AIBinder* volatile*>(&mBinder)) { __assert(__FILE__, __LINE__, "Race detected."); } mBinder = binder; } Loading
libs/binder/ndk/include_ndk/android/binder_interface_utils.h +10 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ #include <android/binder_auto_utils.h> #include <android/binder_ibinder.h> #include <assert.h> #ifdef __cplusplus #include <memory> Loading @@ -39,11 +41,18 @@ namespace ndk { /** * analog using std::shared_ptr for 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. */ class SharedRefBase { public: SharedRefBase() {} virtual ~SharedRefBase() {} virtual ~SharedRefBase() { std::call_once(mFlagThis, [&]() { __assert(__FILE__, __LINE__, "SharedRefBase: no ref created during lifetime"); }); } /** * A shared_ptr must be held to this object when this is called. This must be called once during Loading