aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/support
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2017-11-29 11:25:34 -0800
committerGravatar Mark D. Roth <roth@google.com>2017-11-29 11:25:34 -0800
commitbf816d325e4281804c3f75e63c2c1f7827176300 (patch)
treea94bcb0ffcb6b5fb98e04da5b0056fec2afceb42 /src/core/lib/support
parent240bad3d2d15628ccf13dddfc143e226fc4d9874 (diff)
Shorted "reference" to "ref".
Diffstat (limited to 'src/core/lib/support')
-rw-r--r--src/core/lib/support/ref_counted.h (renamed from src/core/lib/support/reference_counted.h)31
-rw-r--r--src/core/lib/support/ref_counted_ptr.h (renamed from src/core/lib/support/reference_counted_ptr.h)28
2 files changed, 29 insertions, 30 deletions
diff --git a/src/core/lib/support/reference_counted.h b/src/core/lib/support/ref_counted.h
index 3858d61b72..4c662f9119 100644
--- a/src/core/lib/support/reference_counted.h
+++ b/src/core/lib/support/ref_counted.h
@@ -16,8 +16,8 @@
*
*/
-#ifndef GRPC_CORE_LIB_SUPPORT_REFERENCE_COUNTED_H
-#define GRPC_CORE_LIB_SUPPORT_REFERENCE_COUNTED_H
+#ifndef GRPC_CORE_LIB_SUPPORT_REF_COUNTED_H
+#define GRPC_CORE_LIB_SUPPORT_REF_COUNTED_H
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
@@ -31,7 +31,7 @@ namespace grpc_core {
// A base class for reference-counted objects.
// New objects should be created via New() and start with a refcount of 1.
// When the refcount reaches 0, the object will be deleted via Delete().
-class ReferenceCounted {
+class RefCounted {
public:
void Ref() { gpr_ref(&refs_); }
@@ -42,29 +42,29 @@ class ReferenceCounted {
}
// Not copyable nor movable.
- ReferenceCounted(const ReferenceCounted&) = delete;
- ReferenceCounted& operator=(const ReferenceCounted&) = delete;
+ RefCounted(const RefCounted&) = delete;
+ RefCounted& operator=(const RefCounted&) = delete;
protected:
// Allow Delete() to access destructor.
template <typename T>
friend void Delete(T*);
- ReferenceCounted() { gpr_ref_init(&refs_, 1); }
+ RefCounted() { gpr_ref_init(&refs_, 1); }
- virtual ~ReferenceCounted() {}
+ virtual ~RefCounted() {}
private:
gpr_refcount refs_;
};
-// An alternative version of the ReferenceCounted base class that
+// An alternative version of the RefCounted base class that
// supports tracing. This is intended to be used in cases where the
// object will be handled both by idiomatic C++ code using smart
// pointers and legacy code that is manually calling Ref() and Unref().
// Once all of our code is converted to idiomatic C++, we may be able to
// eliminate this class.
-class ReferenceCountedWithTracing {
+class RefCountedWithTracing {
public:
void Ref() { gpr_ref(&refs_); }
@@ -95,23 +95,22 @@ class ReferenceCountedWithTracing {
}
// Not copyable nor movable.
- ReferenceCountedWithTracing(const ReferenceCountedWithTracing&) = delete;
- ReferenceCountedWithTracing& operator=(const ReferenceCountedWithTracing&) =
- delete;
+ RefCountedWithTracing(const RefCountedWithTracing&) = delete;
+ RefCountedWithTracing& operator=(const RefCountedWithTracing&) = delete;
protected:
// Allow Delete() to access destructor.
template <typename T>
friend void Delete(T*);
- ReferenceCountedWithTracing() : ReferenceCountedWithTracing(nullptr) {}
+ RefCountedWithTracing() : RefCountedWithTracing(nullptr) {}
- explicit ReferenceCountedWithTracing(TraceFlag* trace_flag)
+ explicit RefCountedWithTracing(TraceFlag* trace_flag)
: trace_flag_(trace_flag) {
gpr_ref_init(&refs_, 1);
}
- virtual ~ReferenceCountedWithTracing() {}
+ virtual ~RefCountedWithTracing() {}
private:
TraceFlag* trace_flag_ = nullptr;
@@ -120,4 +119,4 @@ class ReferenceCountedWithTracing {
} // namespace grpc_core
-#endif /* GRPC_CORE_LIB_SUPPORT_REFERENCE_COUNTED_H */
+#endif /* GRPC_CORE_LIB_SUPPORT_REF_COUNTED_H */
diff --git a/src/core/lib/support/reference_counted_ptr.h b/src/core/lib/support/ref_counted_ptr.h
index 1590549bfb..dc2385e369 100644
--- a/src/core/lib/support/reference_counted_ptr.h
+++ b/src/core/lib/support/ref_counted_ptr.h
@@ -16,8 +16,8 @@
*
*/
-#ifndef GRPC_CORE_LIB_SUPPORT_REFERENCE_COUNTED_PTR_H
-#define GRPC_CORE_LIB_SUPPORT_REFERENCE_COUNTED_PTR_H
+#ifndef GRPC_CORE_LIB_SUPPORT_REF_COUNTED_PTR_H
+#define GRPC_CORE_LIB_SUPPORT_REF_COUNTED_PTR_H
#include <utility>
@@ -26,21 +26,21 @@
namespace grpc_core {
// A smart pointer class for objects that provide Ref() and Unref() methods,
-// such as those provided by the ReferenceCounted base class.
+// such as those provided by the RefCounted base class.
template <typename T>
-class ReferenceCountedPtr {
+class RefCountedPtr {
public:
- ReferenceCountedPtr() {}
+ RefCountedPtr() {}
// If value is non-null, we take ownership of a ref to it.
- explicit ReferenceCountedPtr(T* value) { value_ = value; }
+ explicit RefCountedPtr(T* value) { value_ = value; }
// Move support.
- ReferenceCountedPtr(ReferenceCountedPtr&& other) {
+ RefCountedPtr(RefCountedPtr&& other) {
value_ = other.value_;
other.value_ = nullptr;
}
- ReferenceCountedPtr& operator=(ReferenceCountedPtr&& other) {
+ RefCountedPtr& operator=(RefCountedPtr&& other) {
if (value_ != nullptr) value_->Unref();
value_ = other.value_;
other.value_ = nullptr;
@@ -48,11 +48,11 @@ class ReferenceCountedPtr {
}
// Copy support.
- ReferenceCountedPtr(const ReferenceCountedPtr& other) {
+ RefCountedPtr(const RefCountedPtr& other) {
if (other.value_ != nullptr) other.value_->Ref();
value_ = other.value_;
}
- ReferenceCountedPtr& operator=(const ReferenceCountedPtr& other) {
+ RefCountedPtr& operator=(const RefCountedPtr& other) {
// Note: Order of reffing and unreffing is important here in case value_
// and other.value_ are the same object.
if (other.value_ != nullptr) other.value_->Ref();
@@ -61,7 +61,7 @@ class ReferenceCountedPtr {
return *this;
}
- ~ReferenceCountedPtr() {
+ ~RefCountedPtr() {
if (value_ != nullptr) value_->Unref();
}
@@ -81,10 +81,10 @@ class ReferenceCountedPtr {
};
template <typename T, typename... Args>
-inline ReferenceCountedPtr<T> MakeReferenceCounted(Args&&... args) {
- return ReferenceCountedPtr<T>(New<T>(std::forward<Args>(args)...));
+inline RefCountedPtr<T> MakeRefCounted(Args&&... args) {
+ return RefCountedPtr<T>(New<T>(std::forward<Args>(args)...));
}
} // namespace grpc_core
-#endif /* GRPC_CORE_LIB_SUPPORT_REFERENCE_COUNTED_PTR_H */
+#endif /* GRPC_CORE_LIB_SUPPORT_REF_COUNTED_PTR_H */