| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 template<typename P1, typename P2, typename P3, typename P4, typename P5, | 89 template<typename P1, typename P2, typename P3, typename P4, typename P5, |
| 90 typename P6, typename P7, typename P8, typename P9, typename P10, | 90 typename P6, typename P7, typename P8, typename P9, typename P10, |
| 91 typename P11> | 91 typename P11> |
| 92 RefCountedObject( | 92 RefCountedObject( |
| 93 P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, | 93 P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, |
| 94 P11 p11) | 94 P11 p11) |
| 95 : T(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11), ref_count_(0) { | 95 : T(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11), ref_count_(0) { |
| 96 } | 96 } |
| 97 | 97 |
| 98 int AddRef() const override { | 98 virtual int AddRef() const { |
| 99 return AtomicOps::Increment(&ref_count_); | 99 return AtomicOps::Increment(&ref_count_); |
| 100 } | 100 } |
| 101 | 101 |
| 102 int Release() const override { | 102 virtual int Release() const { |
| 103 int count = AtomicOps::Decrement(&ref_count_); | 103 int count = AtomicOps::Decrement(&ref_count_); |
| 104 if (!count) { | 104 if (!count) { |
| 105 delete this; | 105 delete this; |
| 106 } | 106 } |
| 107 return count; | 107 return count; |
| 108 } | 108 } |
| 109 | 109 |
| 110 // Return whether the reference count is one. If the reference count is used | 110 // Return whether the reference count is one. If the reference count is used |
| 111 // in the conventional way, a reference count of 1 implies that the current | 111 // in the conventional way, a reference count of 1 implies that the current |
| 112 // thread owns the reference and no other thread shares it. This call | 112 // thread owns the reference and no other thread shares it. This call |
| 113 // performs the test for a reference count of one, and performs the memory | 113 // performs the test for a reference count of one, and performs the memory |
| 114 // barrier needed for the owning thread to act on the object, knowing that it | 114 // barrier needed for the owning thread to act on the object, knowing that it |
| 115 // has exclusive access to the object. | 115 // has exclusive access to the object. |
| 116 virtual bool HasOneRef() const { | 116 virtual bool HasOneRef() const { |
| 117 return AtomicOps::AcquireLoad(&ref_count_) == 1; | 117 return AtomicOps::AcquireLoad(&ref_count_) == 1; |
| 118 } | 118 } |
| 119 | 119 |
| 120 protected: | 120 protected: |
| 121 virtual ~RefCountedObject() { | 121 virtual ~RefCountedObject() { |
| 122 } | 122 } |
| 123 | 123 |
| 124 mutable volatile int ref_count_; | 124 mutable volatile int ref_count_; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 } // namespace rtc | 127 } // namespace rtc |
| 128 | 128 |
| 129 #endif // WEBRTC_BASE_REFCOUNT_H_ | 129 #endif // WEBRTC_BASE_REFCOUNT_H_ |
| OLD | NEW |