| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // Internal implementation details for ref_counted.h. | 5 // Internal implementation details for ref_counted.h. |
| 6 | 6 |
| 7 #ifndef MOJO_EDK_SYSTEM_REF_COUNTED_INTERNAL_H_ | 7 #ifndef MOJO_EDK_UTIL_REF_COUNTED_INTERNAL_H_ |
| 8 #define MOJO_EDK_SYSTEM_REF_COUNTED_INTERNAL_H_ | 8 #define MOJO_EDK_UTIL_REF_COUNTED_INTERNAL_H_ |
| 9 | 9 |
| 10 #include <assert.h> | 10 #include <assert.h> |
| 11 | 11 |
| 12 #include <atomic> | 12 #include <atomic> |
| 13 | 13 |
| 14 #include "mojo/public/cpp/system/macros.h" | 14 #include "mojo/public/cpp/system/macros.h" |
| 15 | 15 |
| 16 namespace mojo { | 16 namespace mojo { |
| 17 namespace system { | 17 namespace util { |
| 18 namespace internal { | 18 namespace internal { |
| 19 | 19 |
| 20 class RefCountedThreadSafeBase { | 20 class RefCountedThreadSafeBase { |
| 21 public: | 21 public: |
| 22 void AddRef() const { | 22 void AddRef() const { |
| 23 assert(!adoption_required_); | 23 assert(!adoption_required_); |
| 24 assert(!destruction_started_); | 24 assert(!destruction_started_); |
| 25 ref_count_.fetch_add(1u, std::memory_order_relaxed); | 25 ref_count_.fetch_add(1u, std::memory_order_relaxed); |
| 26 } | 26 } |
| 27 | 27 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 { | 88 { |
| 89 } | 89 } |
| 90 | 90 |
| 91 inline RefCountedThreadSafeBase::~RefCountedThreadSafeBase() { | 91 inline RefCountedThreadSafeBase::~RefCountedThreadSafeBase() { |
| 92 assert(!adoption_required_); | 92 assert(!adoption_required_); |
| 93 // Should only be destroyed as a result of |Release()|. | 93 // Should only be destroyed as a result of |Release()|. |
| 94 assert(destruction_started_); | 94 assert(destruction_started_); |
| 95 } | 95 } |
| 96 | 96 |
| 97 } // namespace internal | 97 } // namespace internal |
| 98 } // namespace system | 98 } // namespace util |
| 99 } // namespace mojo | 99 } // namespace mojo |
| 100 | 100 |
| 101 #endif // MOJO_EDK_SYSTEM_REF_COUNTED_INTERNAL_H_ | 101 #endif // MOJO_EDK_UTIL_REF_COUNTED_INTERNAL_H_ |
| OLD | NEW |