OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 VM_TIMER_H_ | 5 #ifndef VM_TIMER_H_ |
6 #define VM_TIMER_H_ | 6 #define VM_TIMER_H_ |
7 | 7 |
8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // } | 101 // } |
102 class TimerScope : public StackResource { | 102 class TimerScope : public StackResource { |
103 public: | 103 public: |
104 TimerScope(bool flag, Timer* timer, Thread* thread = NULL) | 104 TimerScope(bool flag, Timer* timer, Thread* thread = NULL) |
105 : StackResource(thread), | 105 : StackResource(thread), |
106 nested_(false), | 106 nested_(false), |
107 timer_(flag ? timer : NULL) { | 107 timer_(flag ? timer : NULL) { |
108 Init(); | 108 Init(); |
109 } | 109 } |
110 | 110 |
111 TimerScope(bool flag, Timer* timer, Isolate* isolate = NULL) | |
112 : StackResource(isolate), | |
113 nested_(false), | |
114 timer_(flag ? timer : NULL) { | |
115 Init(); | |
116 } | |
117 | |
118 void Init() { | 111 void Init() { |
119 if (timer_ != NULL) { | 112 if (timer_ != NULL) { |
120 if (!timer_->running()) { | 113 if (!timer_->running()) { |
121 timer_->Start(); | 114 timer_->Start(); |
122 } else { | 115 } else { |
123 nested_ = true; | 116 nested_ = true; |
124 } | 117 } |
125 } | 118 } |
126 } | 119 } |
127 ~TimerScope() { | 120 ~TimerScope() { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 162 |
170 DISALLOW_ALLOCATION(); | 163 DISALLOW_ALLOCATION(); |
171 DISALLOW_COPY_AND_ASSIGN(PauseTimerScope); | 164 DISALLOW_COPY_AND_ASSIGN(PauseTimerScope); |
172 }; | 165 }; |
173 | 166 |
174 | 167 |
175 | 168 |
176 } // namespace dart | 169 } // namespace dart |
177 | 170 |
178 #endif // VM_TIMER_H_ | 171 #endif // VM_TIMER_H_ |
OLD | NEW |