Index: webrtc/base/refcount.h |
diff --git a/webrtc/base/refcount.h b/webrtc/base/refcount.h |
index 55ce23a348b68a84ce362d98f85c0f871725303a..f655602ab8c78e2f801fcf9127b595501e739a8a 100644 |
--- a/webrtc/base/refcount.h |
+++ b/webrtc/base/refcount.h |
@@ -29,78 +29,128 @@ class RefCountInterface { |
template <class T> |
class RefCountedObject : public T { |
public: |
- RefCountedObject() : ref_count_(0) { |
- } |
+ RefCountedObject() : ref_count_({0}) {} |
- template<typename P> |
- explicit RefCountedObject(P p) : T(p), ref_count_(0) { |
- } |
+ template <typename P> |
+ explicit RefCountedObject(P p) |
+ : T(p), ref_count_({0}) {} |
- template<typename P1, typename P2> |
- RefCountedObject(P1 p1, P2 p2) : T(p1, p2), ref_count_(0) { |
- } |
+ template <typename P1, typename P2> |
+ RefCountedObject(P1 p1, P2 p2) |
+ : T(p1, p2), ref_count_({0}) {} |
- template<typename P1, typename P2, typename P3> |
- RefCountedObject(P1 p1, P2 p2, P3 p3) : T(p1, p2, p3), ref_count_(0) { |
- } |
+ template <typename P1, typename P2, typename P3> |
+ RefCountedObject(P1 p1, P2 p2, P3 p3) |
+ : T(p1, p2, p3), ref_count_({0}) {} |
- template<typename P1, typename P2, typename P3, typename P4> |
+ template <typename P1, typename P2, typename P3, typename P4> |
RefCountedObject(P1 p1, P2 p2, P3 p3, P4 p4) |
- : T(p1, p2, p3, p4), ref_count_(0) { |
- } |
+ : T(p1, p2, p3, p4), ref_count_({0}) {} |
- template<typename P1, typename P2, typename P3, typename P4, typename P5> |
+ template <typename P1, typename P2, typename P3, typename P4, typename P5> |
RefCountedObject(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) |
- : T(p1, p2, p3, p4, p5), ref_count_(0) { |
- } |
- |
- template<typename P1, typename P2, typename P3, typename P4, typename P5, |
- typename P6> |
+ : T(p1, p2, p3, p4, p5), ref_count_({0}) {} |
+ |
+ template <typename P1, |
+ typename P2, |
+ typename P3, |
+ typename P4, |
+ typename P5, |
+ typename P6> |
RefCountedObject(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) |
- : T(p1, p2, p3, p4, p5, p6), ref_count_(0) { |
- } |
- |
- template<typename P1, typename P2, typename P3, typename P4, typename P5, |
- typename P6, typename P7> |
+ : T(p1, p2, p3, p4, p5, p6), ref_count_({0}) {} |
+ |
+ template <typename P1, |
+ typename P2, |
+ typename P3, |
+ typename P4, |
+ typename P5, |
+ typename P6, |
+ typename P7> |
RefCountedObject(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) |
- : T(p1, p2, p3, p4, p5, p6, p7), ref_count_(0) { |
- } |
- |
- template<typename P1, typename P2, typename P3, typename P4, typename P5, |
- typename P6, typename P7, typename P8> |
+ : T(p1, p2, p3, p4, p5, p6, p7), ref_count_({0}) {} |
+ |
+ template <typename P1, |
+ typename P2, |
+ typename P3, |
+ typename P4, |
+ typename P5, |
+ typename P6, |
+ typename P7, |
+ typename P8> |
RefCountedObject(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) |
- : T(p1, p2, p3, p4, p5, p6, p7, p8), ref_count_(0) { |
- } |
- |
- template<typename P1, typename P2, typename P3, typename P4, typename P5, |
- typename P6, typename P7, typename P8, typename P9> |
- RefCountedObject( |
- P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9) |
- : T(p1, p2, p3, p4, p5, p6, p7, p8, p9), ref_count_(0) { |
- } |
- |
- template<typename P1, typename P2, typename P3, typename P4, typename P5, |
- typename P6, typename P7, typename P8, typename P9, typename P10> |
- RefCountedObject( |
- P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10) |
- : T(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10), ref_count_(0) { |
- } |
- |
- template<typename P1, typename P2, typename P3, typename P4, typename P5, |
- typename P6, typename P7, typename P8, typename P9, typename P10, |
- typename P11> |
- RefCountedObject( |
- P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, |
- P11 p11) |
- : T(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11), ref_count_(0) { |
- } |
- |
- virtual int AddRef() const { |
- return AtomicOps::Increment(&ref_count_); |
- } |
+ : T(p1, p2, p3, p4, p5, p6, p7, p8), ref_count_({0}) {} |
+ |
+ template <typename P1, |
+ typename P2, |
+ typename P3, |
+ typename P4, |
+ typename P5, |
+ typename P6, |
+ typename P7, |
+ typename P8, |
+ typename P9> |
+ RefCountedObject(P1 p1, |
+ P2 p2, |
+ P3 p3, |
+ P4 p4, |
+ P5 p5, |
+ P6 p6, |
+ P7 p7, |
+ P8 p8, |
+ P9 p9) |
+ : T(p1, p2, p3, p4, p5, p6, p7, p8, p9), ref_count_({0}) {} |
+ |
+ template <typename P1, |
+ typename P2, |
+ typename P3, |
+ typename P4, |
+ typename P5, |
+ typename P6, |
+ typename P7, |
+ typename P8, |
+ typename P9, |
+ typename P10> |
+ RefCountedObject(P1 p1, |
+ P2 p2, |
+ P3 p3, |
+ P4 p4, |
+ P5 p5, |
+ P6 p6, |
+ P7 p7, |
+ P8 p8, |
+ P9 p9, |
+ P10 p10) |
+ : T(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10), ref_count_({0}) {} |
+ |
+ template <typename P1, |
+ typename P2, |
+ typename P3, |
+ typename P4, |
+ typename P5, |
+ typename P6, |
+ typename P7, |
+ typename P8, |
+ typename P9, |
+ typename P10, |
+ typename P11> |
+ RefCountedObject(P1 p1, |
+ P2 p2, |
+ P3 p3, |
+ P4 p4, |
+ P5 p5, |
+ P6 p6, |
+ P7 p7, |
+ P8 p8, |
+ P9 p9, |
+ P10 p10, |
+ P11 p11) |
+ : T(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11), ref_count_({0}) {} |
+ |
+ virtual int AddRef() const { return AtomicInt::Increment(&ref_count_); } |
virtual int Release() const { |
- int count = AtomicOps::Decrement(&ref_count_); |
+ int count = AtomicInt::Decrement(&ref_count_); |
if (!count) { |
delete this; |
} |
@@ -114,14 +164,14 @@ class RefCountedObject : public T { |
// barrier needed for the owning thread to act on the object, knowing that it |
// has exclusive access to the object. |
virtual bool HasOneRef() const { |
- return AtomicOps::AcquireLoad(&ref_count_) == 1; |
+ return AtomicInt::AcquireLoad(&ref_count_) == 1; |
} |
protected: |
virtual ~RefCountedObject() { |
} |
- mutable volatile int ref_count_; |
+ mutable AtomicInt ref_count_; |
}; |
} // namespace rtc |