OLD | NEW |
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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 | 376 |
377 bool ThreadPool::Worker::Loop() { | 377 bool ThreadPool::Worker::Loop() { |
378 MonitorLocker ml(&monitor_); | 378 MonitorLocker ml(&monitor_); |
379 int64_t idle_start; | 379 int64_t idle_start; |
380 while (true) { | 380 while (true) { |
381 ASSERT(task_ != NULL); | 381 ASSERT(task_ != NULL); |
382 Task* task = task_; | 382 Task* task = task_; |
383 task_ = NULL; | 383 task_ = NULL; |
384 | 384 |
385 // Release monitor while handling the task. | 385 // Release monitor while handling the task. |
386 monitor_.Exit(); | 386 ml.Exit(); |
387 task->Run(); | 387 task->Run(); |
388 ASSERT(Isolate::Current() == NULL); | 388 ASSERT(Isolate::Current() == NULL); |
389 delete task; | 389 delete task; |
390 monitor_.Enter(); | 390 ml.Enter(); |
391 | 391 |
392 ASSERT(task_ == NULL); | 392 ASSERT(task_ == NULL); |
393 if (IsDone()) { | 393 if (IsDone()) { |
394 return false; | 394 return false; |
395 } | 395 } |
396 ASSERT(!done_); | 396 ASSERT(!done_); |
397 pool_->SetIdleAndReapExited(this); | 397 pool_->SetIdleAndReapExited(this); |
398 idle_start = OS::GetCurrentTimeMillis(); | 398 idle_start = OS::GetCurrentTimeMillis(); |
399 while (true) { | 399 while (true) { |
400 Monitor::WaitResult result = ml.Wait(ComputeTimeout(idle_start)); | 400 Monitor::WaitResult result = ml.Wait(ComputeTimeout(idle_start)); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 // is not due to a ThreadPool Shutdown. Thus, we simply delete the worker. | 476 // is not due to a ThreadPool Shutdown. Thus, we simply delete the worker. |
477 // The worker's id is added to the thread pool's join list by | 477 // The worker's id is added to the thread pool's join list by |
478 // ReleaseIdleWorker, so in the case that the thread pool begins shutting | 478 // ReleaseIdleWorker, so in the case that the thread pool begins shutting |
479 // down immediately after returning from worker->Loop() above, we still | 479 // down immediately after returning from worker->Loop() above, we still |
480 // wait for the thread to exit by joining on it in Shutdown(). | 480 // wait for the thread to exit by joining on it in Shutdown(). |
481 delete worker; | 481 delete worker; |
482 } | 482 } |
483 } | 483 } |
484 | 484 |
485 } // namespace dart | 485 } // namespace dart |
OLD | NEW |