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

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

Issue 1261923008: Begin migration of InterruptableThreadState into Thread. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Parentheses. Created 5 years, 4 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 | « runtime/vm/thread_interrupter.h ('k') | runtime/vm/thread_test.cc » ('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) 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 "Trace thread interrupter"); 49 "Trace thread interrupter");
50 50
51 bool ThreadInterrupter::initialized_ = false; 51 bool ThreadInterrupter::initialized_ = false;
52 bool ThreadInterrupter::shutdown_ = false; 52 bool ThreadInterrupter::shutdown_ = false;
53 bool ThreadInterrupter::thread_running_ = false; 53 bool ThreadInterrupter::thread_running_ = false;
54 ThreadId ThreadInterrupter::interrupter_thread_id_ = 54 ThreadId ThreadInterrupter::interrupter_thread_id_ =
55 OSThread::kInvalidThreadId; 55 OSThread::kInvalidThreadId;
56 Monitor* ThreadInterrupter::monitor_ = NULL; 56 Monitor* ThreadInterrupter::monitor_ = NULL;
57 intptr_t ThreadInterrupter::interrupt_period_ = 1000; 57 intptr_t ThreadInterrupter::interrupt_period_ = 1000;
58 intptr_t ThreadInterrupter::current_wait_time_ = Monitor::kNoTimeout; 58 intptr_t ThreadInterrupter::current_wait_time_ = Monitor::kNoTimeout;
59 ThreadLocalKey ThreadInterrupter::thread_state_key_ =
60 OSThread::kUnsetThreadLocalKey;
61 59
62 60
63 void ThreadInterrupter::InitOnce() { 61 void ThreadInterrupter::InitOnce() {
64 ASSERT(!initialized_); 62 ASSERT(!initialized_);
65 ASSERT(thread_state_key_ == OSThread::kUnsetThreadLocalKey);
66 thread_state_key_ = OSThread::CreateThreadLocal();
67 ASSERT(thread_state_key_ != OSThread::kUnsetThreadLocalKey);
68 monitor_ = new Monitor(); 63 monitor_ = new Monitor();
69 ASSERT(monitor_ != NULL); 64 ASSERT(monitor_ != NULL);
70 initialized_ = true; 65 initialized_ = true;
71 } 66 }
72 67
73 68
74 void ThreadInterrupter::Startup() { 69 void ThreadInterrupter::Startup() {
75 ASSERT(initialized_); 70 ASSERT(initialized_);
76 if (FLAG_trace_thread_interrupter) { 71 if (FLAG_trace_thread_interrupter) {
77 OS::Print("ThreadInterrupter starting up.\n"); 72 OS::Print("ThreadInterrupter starting up.\n");
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } 219 }
225 } 220 }
226 221
227 222
228 InterruptableThreadState* ThreadInterrupter::GetCurrentThreadState() { 223 InterruptableThreadState* ThreadInterrupter::GetCurrentThreadState() {
229 return _EnsureThreadStateCreated(); 224 return _EnsureThreadStateCreated();
230 } 225 }
231 226
232 227
233 InterruptableThreadState* ThreadInterrupter::CurrentThreadState() { 228 InterruptableThreadState* ThreadInterrupter::CurrentThreadState() {
234 InterruptableThreadState* state = reinterpret_cast<InterruptableThreadState*>( 229 return Thread::Current()->thread_state();
235 OSThread::GetThreadLocal(thread_state_key_));
236 return state;
237 } 230 }
238 231
239 232
240 void ThreadInterrupter::SetCurrentThreadState(InterruptableThreadState* state) { 233 void ThreadInterrupter::SetCurrentThreadState(InterruptableThreadState* state) {
241 OSThread::SetThreadLocal(thread_state_key_, 234 Thread::Current()->set_thread_state(state);
242 reinterpret_cast<uword>(state));
243 } 235 }
244 236
245 237
246 void ThreadInterruptNoOp(const InterruptedThreadState& state, void* data) { 238 void ThreadInterruptNoOp(const InterruptedThreadState& state, void* data) {
247 // NoOp. 239 // NoOp.
248 } 240 }
249 241
250 242
251 class ThreadInterrupterVisitIsolates : public IsolateVisitor { 243 class ThreadInterrupterVisitIsolates : public IsolateVisitor {
252 public: 244 public:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 312 }
321 { 313 {
322 // Signal to main thread we are exiting. 314 // Signal to main thread we are exiting.
323 MonitorLocker shutdown_ml(monitor_); 315 MonitorLocker shutdown_ml(monitor_);
324 thread_running_ = false; 316 thread_running_ = false;
325 shutdown_ml.Notify(); 317 shutdown_ml.Notify();
326 } 318 }
327 } 319 }
328 320
329 } // namespace dart 321 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/thread_interrupter.h ('k') | runtime/vm/thread_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698