15 #ifndef GRPC_CORE_EXT_TRANSPORT_BINDER_UTILS_BINDER_AUTO_UTILS_H
16 #define GRPC_CORE_EXT_TRANSPORT_BINDER_UTILS_BINDER_AUTO_UTILS_H
20 #ifdef GPR_SUPPORT_BINDER_TRANSPORT
33 SpAIBinder() : mBinder(nullptr) {}
34 explicit SpAIBinder(AIBinder* binder) : mBinder(binder) {}
35 SpAIBinder(std::nullptr_t)
37 SpAIBinder(
const SpAIBinder& other) { *
this = other; }
39 ~SpAIBinder() {
set(
nullptr); }
40 SpAIBinder& operator=(
const SpAIBinder& other) {
44 AIBinder_incStrong(other.mBinder);
49 void set(AIBinder* binder) {
50 AIBinder*
old = *
const_cast<AIBinder* volatile*
>(&mBinder);
51 if (
old !=
nullptr) AIBinder_decStrong(
old);
52 if (
old != *
const_cast<AIBinder* volatile*
>(&mBinder)) {
53 __assert(__FILE__, __LINE__,
"Race detected.");
58 AIBinder*
get()
const {
return mBinder; }
59 AIBinder** getR() {
return &mBinder; }
61 bool operator!=(
const SpAIBinder& rhs)
const {
return get() != rhs.get(); }
62 bool operator<(
const SpAIBinder& rhs)
const {
return get() < rhs.get(); }
63 bool operator<=(
const SpAIBinder& rhs)
const {
return get() <= rhs.get(); }
64 bool operator==(
const SpAIBinder& rhs)
const {
return get() == rhs.get(); }
65 bool operator>(
const SpAIBinder& rhs)
const {
return get() > rhs.get(); }
66 bool operator>=(
const SpAIBinder& rhs)
const {
return get() >= rhs.get(); }
69 AIBinder* mBinder =
nullptr;
76 #endif // GRPC_CORE_EXT_TRANSPORT_BINDER_UTILS_BINDER_AUTO_UTILS_H