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/dart.h" |
7 #include "vm/flags.h" | 8 #include "vm/flags.h" |
8 #include "vm/lockers.h" | 9 #include "vm/lockers.h" |
9 | 10 |
10 namespace dart { | 11 namespace dart { |
11 | 12 |
12 DEFINE_FLAG(int, worker_timeout_millis, 5000, | 13 DEFINE_FLAG(int, worker_timeout_millis, 5000, |
13 "Free workers when they have been idle for this amount of time."); | 14 "Free workers when they have been idle for this amount of time."); |
14 | 15 |
15 ThreadPool::ThreadPool() | 16 ThreadPool::ThreadPool() |
16 : shutting_down_(false), | 17 : shutting_down_(false), |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 } | 474 } |
474 } else { | 475 } else { |
475 // This worker is going down because it was idle for too long. This case | 476 // This worker is going down because it was idle for too long. This case |
476 // is not due to a ThreadPool Shutdown. Thus, we simply delete the worker. | 477 // 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 | 478 // 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 | 479 // ReleaseIdleWorker, so in the case that the thread pool begins shutting |
479 // down immediately after returning from worker->Loop() above, we still | 480 // down immediately after returning from worker->Loop() above, we still |
480 // wait for the thread to exit by joining on it in Shutdown(). | 481 // wait for the thread to exit by joining on it in Shutdown(). |
481 delete worker; | 482 delete worker; |
482 } | 483 } |
| 484 |
| 485 // Call the thread exit hook here to notify the embedder that the |
| 486 // thread pool thread is exiting. |
| 487 if (Dart::thread_exit_callback() != NULL) { |
| 488 (*Dart::thread_exit_callback())(); |
| 489 } |
483 } | 490 } |
484 | 491 |
485 } // namespace dart | 492 } // namespace dart |
OLD | NEW |