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

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

Issue 1041523002: Refactor Thread lifecycle interface, add Thread::Enter/ExitIsolate. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/thread.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_pool.h" 5 #include "vm/thread_pool.h"
6 6
7 #include "vm/flags.h" 7 #include "vm/flags.h"
8 #include "vm/lockers.h" 8 #include "vm/lockers.h"
9 9
10 namespace dart { 10 namespace dart {
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 void ThreadPool::Worker::Loop() { 267 void ThreadPool::Worker::Loop() {
268 MonitorLocker ml(&monitor_); 268 MonitorLocker ml(&monitor_);
269 int64_t idle_start; 269 int64_t idle_start;
270 while (true) { 270 while (true) {
271 ASSERT(task_ != NULL); 271 ASSERT(task_ != NULL);
272 Task* task = task_; 272 Task* task = task_;
273 task_ = NULL; 273 task_ = NULL;
274 274
275 // Release monitor while handling the task. 275 // Release monitor while handling the task.
276 monitor_.Exit(); 276 monitor_.Exit();
277 Thread::EnsureInit();
277 task->Run(); 278 task->Run();
279 ASSERT(Isolate::Current() == NULL);
280 // Prevent unintended sharing of state between tasks.
281 Thread::CleanUp();
278 delete task; 282 delete task;
279 monitor_.Enter(); 283 monitor_.Enter();
280 284
281 ASSERT(task_ == NULL); 285 ASSERT(task_ == NULL);
282 if (IsDone()) { 286 if (IsDone()) {
283 return; 287 return;
284 } 288 }
285 ASSERT(pool_ != NULL); 289 ASSERT(pool_ != NULL);
286 pool_->SetIdle(this); 290 pool_->SetIdle(this);
287 idle_start = OS::GetCurrentTimeMillis(); 291 idle_start = OS::GetCurrentTimeMillis();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 // The exit monitor is only used during testing. 329 // The exit monitor is only used during testing.
326 if (ThreadPool::exit_monitor_) { 330 if (ThreadPool::exit_monitor_) {
327 MonitorLocker ml(ThreadPool::exit_monitor_); 331 MonitorLocker ml(ThreadPool::exit_monitor_);
328 (*ThreadPool::exit_count_)++; 332 (*ThreadPool::exit_count_)++;
329 ml.Notify(); 333 ml.Notify();
330 } 334 }
331 delete worker; 335 delete worker;
332 } 336 }
333 337
334 } // namespace dart 338 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/thread.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698