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

Side by Side Diff: runtime/vm/thread_interrupter.cc

Issue 1765533003: Fix some potential data races based on output from tsan. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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
« runtime/vm/class_table.cc ('K') | « runtime/vm/class_table.cc ('k') | no next file » | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 #include "vm/thread_interrupter.h" 5 #include "vm/thread_interrupter.h"
6 6
7 #include "vm/flags.h" 7 #include "vm/flags.h"
8 #include "vm/lockers.h" 8 #include "vm/lockers.h"
9 #include "vm/os.h" 9 #include "vm/os.h"
10 #include "vm/simulator.h" 10 #include "vm/simulator.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // Signal to main thread we are ready. 156 // Signal to main thread we are ready.
157 MonitorLocker startup_ml(monitor_); 157 MonitorLocker startup_ml(monitor_);
158 OSThread* os_thread = OSThread::Current(); 158 OSThread* os_thread = OSThread::Current();
159 ASSERT(os_thread != NULL); 159 ASSERT(os_thread != NULL);
160 interrupter_thread_id_ = os_thread->join_id(); 160 interrupter_thread_id_ = os_thread->join_id();
161 thread_running_ = true; 161 thread_running_ = true;
162 startup_ml.Notify(); 162 startup_ml.Notify();
163 } 163 }
164 { 164 {
165 intptr_t interrupted_thread_count = 0; 165 intptr_t interrupted_thread_count = 0;
166 MonitorLocker wait_ml(monitor_);
166 current_wait_time_ = interrupt_period_; 167 current_wait_time_ = interrupt_period_;
167 MonitorLocker wait_ml(monitor_);
168 while (!shutdown_) { 168 while (!shutdown_) {
169 intptr_t r = wait_ml.WaitMicros(current_wait_time_); 169 intptr_t r = wait_ml.WaitMicros(current_wait_time_);
170 170
171 if (shutdown_) { 171 if (shutdown_) {
172 break; 172 break;
173 } 173 }
174 174
175 if ((r == Monitor::kNotified) && InDeepSleep()) { 175 if ((r == Monitor::kNotified) && InDeepSleep()) {
176 // Woken up from deep sleep. 176 // Woken up from deep sleep.
177 ASSERT(interrupted_thread_count == 0); 177 ASSERT(interrupted_thread_count == 0);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // Signal to main thread we are exiting. 222 // Signal to main thread we are exiting.
223 MonitorLocker shutdown_ml(monitor_); 223 MonitorLocker shutdown_ml(monitor_);
224 thread_running_ = false; 224 thread_running_ = false;
225 shutdown_ml.Notify(); 225 shutdown_ml.Notify();
226 } 226 }
227 } 227 }
228 228
229 #endif // !PRODUCT 229 #endif // !PRODUCT
230 230
231 } // namespace dart 231 } // namespace dart
OLDNEW
« runtime/vm/class_table.cc ('K') | « runtime/vm/class_table.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698