Merge "setDefaultImpl aborts on a second call" am: 196feae688
Change-Id: Ieea885b8da74402cb90fcd0ba391b63bc1dd4a4a
This commit is contained in:
commit
2804e79b5c
1 changed files with 7 additions and 1 deletions
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include <binder/Binder.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -155,7 +157,11 @@ public: \
|
|||
std::unique_ptr<I##INTERFACE> I##INTERFACE::default_impl; \
|
||||
bool I##INTERFACE::setDefaultImpl(std::unique_ptr<I##INTERFACE> impl)\
|
||||
{ \
|
||||
if (!I##INTERFACE::default_impl && impl) { \
|
||||
/* Only one user of this interface can use this function */ \
|
||||
/* at a time. This is a heuristic to detect if two different */ \
|
||||
/* users in the same process use this function. */ \
|
||||
assert(!I##INTERFACE::default_impl); \
|
||||
if (impl) { \
|
||||
I##INTERFACE::default_impl = std::move(impl); \
|
||||
return true; \
|
||||
} \
|
||||
|
|
Loading…
Reference in a new issue