Update by review

pull/20962/head
Esun Kim 5 years ago
parent 3a519a0b64
commit 3d3577e28d
  1. 12
      src/core/lib/gprpp/memory.h
  2. 4
      src/core/lib/gprpp/orphanable.h
  3. 4
      src/core/lib/gprpp/ref_counted.h

@ -30,18 +30,6 @@
namespace grpc_core {
// Gets the base pointer of any class, in case of multiple inheritance.
// Used by Delete and friends.
template <typename T, bool isPolymorphic>
struct BasePointerGetter {
static void* get(T* p) { return p; }
};
template <typename T>
struct BasePointerGetter<T, true> {
static void* get(T* p) { return dynamic_cast<void*>(p); }
};
template <typename T>
using UniquePtr = std::unique_ptr<T>;

@ -106,12 +106,12 @@ class InternallyRefCounted : public Orphanable {
void Unref() {
if (GPR_UNLIKELY(refs_.Unref())) {
delete static_cast<Child*>(this);
delete this;
}
}
void Unref(const DebugLocation& location, const char* reason) {
if (GPR_UNLIKELY(refs_.Unref(location, reason))) {
delete static_cast<Child*>(this);
delete this;
}
}

@ -267,12 +267,12 @@ class RefCounted : public Impl {
// friend of this class.
void Unref() {
if (GPR_UNLIKELY(refs_.Unref())) {
delete static_cast<Child*>(this);
delete this;
}
}
void Unref(const DebugLocation& location, const char* reason) {
if (GPR_UNLIKELY(refs_.Unref(location, reason))) {
delete static_cast<Child*>(this);
delete this;
}
}

Loading…
Cancel
Save