aboutsummaryrefslogtreecommitdiff
path: root/src/core/lib/gprpp/ref_counted.h
diff options
context:
space:
mode:
authorSoheil Hassas Yeganeh <soheil@google.com>2019-02-20 11:28:16 -0500
committerSoheil Hassas Yeganeh <soheil@google.com>2019-02-20 11:42:33 -0500
commit1ccdb0ee265a02cda9751d43f74ee7285ecdae60 (patch)
tree385a7e015abc75acef0d74e53c97823e19d165d2 /src/core/lib/gprpp/ref_counted.h
parent508c8d805a1fe3dda77ebda27386597a7af1073c (diff)
downloadgrpc-grpc-1ccdb0ee265a02cda9751d43f74ee7285ecdae60.tar.gz
Alias std::memory_order as grpc_core::MemoryOrder.
Diffstat (limited to 'src/core/lib/gprpp/ref_counted.h')
-rw-r--r--src/core/lib/gprpp/ref_counted.h12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/core/lib/gprpp/ref_counted.h b/src/core/lib/gprpp/ref_counted.h
index b0430b6b80..8148cfd35d 100644
--- a/src/core/lib/gprpp/ref_counted.h
+++ b/src/core/lib/gprpp/ref_counted.h
@@ -89,9 +89,7 @@ class RefCount {
}
// Increases the ref-count by `n`.
- void Ref(Value n = 1) {
- AtomicFetchAdd(&value_, n, std::memory_order_relaxed);
- }
+ void Ref(Value n = 1) { AtomicFetchAdd(&value_, n, MemoryOrder::RELAXED); }
void Ref(const DebugLocation& location, const char* reason, Value n = 1) {
#ifndef NDEBUG
if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) {
@@ -107,7 +105,7 @@ class RefCount {
// Similar to Ref() with an assert on the ref-count being non-zero.
void RefNonZero() {
#ifndef NDEBUG
- const Value prior = AtomicFetchAdd(&value_, 1, std::memory_order_relaxed);
+ const Value prior = AtomicFetchAdd(&value_, 1, MemoryOrder::RELAXED);
assert(prior > 0);
#else
Ref();
@@ -127,7 +125,7 @@ class RefCount {
// Decrements the ref-count and returns true if the ref-count reaches 0.
bool Unref() {
- const Value prior = AtomicFetchSub(&value_, 1, std::memory_order_acq_rel);
+ const Value prior = AtomicFetchSub(&value_, 1, MemoryOrder::ACQ_REL);
GPR_DEBUG_ASSERT(prior > 0);
return prior == 1;
}
@@ -144,12 +142,12 @@ class RefCount {
}
private:
- Value get() const { return value_.load(std::memory_order_relaxed); }
+ Value get() const { return AtomicLoad(&value_, MemoryOrder::RELAXED); }
#ifndef NDEBUG
TraceFlag* trace_flag_;
#endif
- std::atomic<Value> value_;
+ Atomic<Value> value_;
};
// A base class for reference-counted objects.