OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_MEMORY_REF_COUNTED_H_ | 5 #ifndef BASE_MEMORY_REF_COUNTED_H_ |
6 #define BASE_MEMORY_REF_COUNTED_H_ | 6 #define BASE_MEMORY_REF_COUNTED_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <cassert> | 10 #include <cassert> |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 if (--ref_count_ == 0) { | 68 if (--ref_count_ == 0) { |
69 #ifndef NDEBUG | 69 #ifndef NDEBUG |
70 in_dtor_ = true; | 70 in_dtor_ = true; |
71 #endif | 71 #endif |
72 return true; | 72 return true; |
73 } | 73 } |
74 return false; | 74 return false; |
75 } | 75 } |
76 | 76 |
77 private: | 77 private: |
78 mutable int ref_count_; | 78 mutable size_t ref_count_; |
Tom Sepez
2016/09/22 17:55:35
nit: should really be an intprt_t, in case we go b
| |
79 #ifndef NDEBUG | 79 #ifndef NDEBUG |
80 mutable bool in_dtor_; | 80 mutable bool in_dtor_; |
81 #endif | 81 #endif |
82 | 82 |
83 DFAKE_MUTEX(add_release_); | 83 DFAKE_MUTEX(add_release_); |
84 | 84 |
85 DISALLOW_COPY_AND_ASSIGN(RefCountedBase); | 85 DISALLOW_COPY_AND_ASSIGN(RefCountedBase); |
86 }; | 86 }; |
87 | 87 |
88 class BASE_EXPORT RefCountedThreadSafeBase { | 88 class BASE_EXPORT RefCountedThreadSafeBase { |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
453 bool operator!=(std::nullptr_t null, const scoped_refptr<T>& rhs) { | 453 bool operator!=(std::nullptr_t null, const scoped_refptr<T>& rhs) { |
454 return !operator==(null, rhs); | 454 return !operator==(null, rhs); |
455 } | 455 } |
456 | 456 |
457 template <typename T> | 457 template <typename T> |
458 std::ostream& operator<<(std::ostream& out, const scoped_refptr<T>& p) { | 458 std::ostream& operator<<(std::ostream& out, const scoped_refptr<T>& p) { |
459 return out << p.get(); | 459 return out << p.get(); |
460 } | 460 } |
461 | 461 |
462 #endif // BASE_MEMORY_REF_COUNTED_H_ | 462 #endif // BASE_MEMORY_REF_COUNTED_H_ |
OLD | NEW |