Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: src/vm/refcounted.h

Issue 1659163007: Rename fletch -> dartino (Closed) Base URL: https://github.com/dartino/sdk.git@master
Patch Set: address comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/vm/program_relocator.cc ('k') | src/vm/remembered_set.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dartino 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 #ifndef SRC_VM_REFCOUNTED_H_ 5 #ifndef SRC_VM_REFCOUNTED_H_
6 #define SRC_VM_REFCOUNTED_H_ 6 #define SRC_VM_REFCOUNTED_H_
7 7
8 #include "src/shared/globals.h" 8 #include "src/shared/globals.h"
9 #include "src/shared/atomic.h" 9 #include "src/shared/atomic.h"
10 10
11 namespace fletch { 11 namespace dartino {
12 12
13 template <typename T> 13 template <typename T>
14 class Refcounted { 14 class Refcounted {
15 public: 15 public:
16 Refcounted() : ref_count_(1) {} 16 Refcounted() : ref_count_(1) {}
17 ~Refcounted() { ASSERT(ref_count_ == 0); } 17 ~Refcounted() { ASSERT(ref_count_ == 0); }
18 18
19 void IncrementRef() { 19 void IncrementRef() {
20 ASSERT(ref_count_ > 0); 20 ASSERT(ref_count_ > 0);
21 ref_count_++; 21 ref_count_++;
22 } 22 }
23 23
24 static void DecrementRef(T* object) { 24 static void DecrementRef(T* object) {
25 ASSERT(object->ref_count_ > 0); 25 ASSERT(object->ref_count_ > 0);
26 if (--object->ref_count_ == 0) { 26 if (--object->ref_count_ == 0) {
27 delete reinterpret_cast<T*>(object); 27 delete reinterpret_cast<T*>(object);
28 } 28 }
29 } 29 }
30 30
31 private: 31 private:
32 Atomic<int> ref_count_; 32 Atomic<int> ref_count_;
33 }; 33 };
34 34
35 } // namespace fletch 35 } // namespace dartino
36 36
37 #endif // SRC_VM_REFCOUNTED_H_ 37 #endif // SRC_VM_REFCOUNTED_H_
OLDNEW
« no previous file with comments | « src/vm/program_relocator.cc ('k') | src/vm/remembered_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698