OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef RUNTIME_BIN_REFERENCE_COUNTING_H_ | 5 #ifndef RUNTIME_BIN_REFERENCE_COUNTING_H_ |
6 #define RUNTIME_BIN_REFERENCE_COUNTING_H_ | 6 #define RUNTIME_BIN_REFERENCE_COUNTING_H_ |
7 | 7 |
8 #include "vm/atomic.h" | 8 #include "vm/atomic.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 friend class RefCntReleaseScope<Derived>; | 75 friend class RefCntReleaseScope<Derived>; |
76 DISALLOW_COPY_AND_ASSIGN(ReferenceCounted); | 76 DISALLOW_COPY_AND_ASSIGN(ReferenceCounted); |
77 }; | 77 }; |
78 | 78 |
79 #if defined(DEBUG) | 79 #if defined(DEBUG) |
80 template <class Derived> | 80 template <class Derived> |
81 intptr_t ReferenceCounted<Derived>::instances_ = 0; | 81 intptr_t ReferenceCounted<Derived>::instances_ = 0; |
82 #endif | 82 #endif |
83 | 83 |
84 // Creates a scope at the end of which a reference counted object is | 84 // Creates a scope at the end of which a reference counted object is |
85 // Released. This is useful for reference counted objects recieved by the IO | 85 // Released. This is useful for reference counted objects received by the IO |
86 // Service, which have already been Retained E.g.: | 86 // Service, which have already been Retained E.g.: |
87 // | 87 // |
88 // CObject* Foo::FooRequest(const CObjectArray& request) { | 88 // CObject* Foo::FooRequest(const CObjectArray& request) { |
89 // Foo* foo = CObjectToFoo(request[0]); | 89 // Foo* foo = CObjectToFoo(request[0]); |
90 // RefCntReleaseScope<Foo> rs(foo); | 90 // RefCntReleaseScope<Foo> rs(foo); |
91 // ... | 91 // ... |
92 // } | 92 // } |
93 template <class Target> | 93 template <class Target> |
94 class RefCntReleaseScope { | 94 class RefCntReleaseScope { |
95 public: | 95 public: |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 ReferenceCounted<Target>* target_; | 165 ReferenceCounted<Target>* target_; |
166 | 166 |
167 DISALLOW_ALLOCATION(); | 167 DISALLOW_ALLOCATION(); |
168 DISALLOW_COPY_AND_ASSIGN(RetainedPointer); | 168 DISALLOW_COPY_AND_ASSIGN(RetainedPointer); |
169 }; | 169 }; |
170 | 170 |
171 } // namespace bin | 171 } // namespace bin |
172 } // namespace dart | 172 } // namespace dart |
173 | 173 |
174 #endif // RUNTIME_BIN_REFERENCE_COUNTING_H_ | 174 #endif // RUNTIME_BIN_REFERENCE_COUNTING_H_ |
OLD | NEW |