Chromium Code Reviews| Index: runtime/bin/thread_pool.cc |
| diff --git a/runtime/bin/thread_pool.cc b/runtime/bin/thread_pool.cc |
| index 36960a72303b798454eb01b72b3cfa802a1044ce..b5715154433529f51987c4937a83afa3234c4bd6 100644 |
| --- a/runtime/bin/thread_pool.cc |
| +++ b/runtime/bin/thread_pool.cc |
| @@ -63,7 +63,30 @@ Task ThreadPool::WaitForTask() { |
| } |
| -void* ThreadPool::Main(void* args) { |
| +void ThreadPool::Start() { |
| + threads_ |
| + = reinterpret_cast<dart::ThreadHandle*>( |
| + calloc(size_, sizeof(dart::ThreadHandle))); |
|
Mads Ager (google)
2012/01/20 12:35:34
I think we usually use 4-space indent we we have t
Søren Gjesse
2012/01/20 13:25:45
Done.
|
| + for (int i = 0; i < size_; i++) { |
| + threads_[i] = dart::Thread::Start(&ThreadPool::Main, |
| + reinterpret_cast<uword>(this)); |
| + if (threads_[i] == dart::Thread::kInvalidThreadHandle) { |
| + FATAL("Create and start thread pool thread"); |
| + } |
| + } |
| +} |
| + |
| + |
| +void ThreadPool::Shutdown() { |
| + terminate_ = true; |
| + queue_.Shutdown(); |
| + for (int i = 0; i < size_; i++) { |
| + dart::Thread::Join(threads_[i]); |
| + } |
| +} |
| + |
| + |
| +void ThreadPool::Main(uword args) { |
| if (Dart_IsVMFlagSet("trace_thread_pool")) { |
| printf("Thread pool thread started\n"); |
| } |
| @@ -73,8 +96,7 @@ void* ThreadPool::Main(void* args) { |
| printf("Waiting for task\n"); |
| } |
| Task task = pool->WaitForTask(); |
| - if (pool->terminate_) return NULL; |
| + if (pool->terminate_) return; |
| (*(pool->task_handler_))(task); |
| } |
| - return NULL; |
| }; |