Chromium Code Reviews| Index: runtime/bin/thread_pool.cc |
| diff --git a/runtime/bin/thread_pool.cc b/runtime/bin/thread_pool.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..381b608b5a2417a7288e3b918429aad3f6b03954 |
| --- /dev/null |
| +++ b/runtime/bin/thread_pool.cc |
| @@ -0,0 +1,38 @@ |
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +#include "bin/thread_pool.h" |
| + |
| +void ThreadPool::Shutdown() { |
| + UNIMPLEMENTED(); |
| +} |
| + |
| + |
| +void ThreadPool::InsertTask(Task task) { |
| + TaskQueueEntry* entry = new TaskQueueEntry(task); |
| + queue.Insert(entry); |
| +} |
| + |
| + |
| +Task ThreadPool::WaitForTask() { |
| + TaskQueueEntry* entry = queue.Remove(); |
| + if (entry == NULL) { |
| + return -1; |
| + } |
| + Task task = entry->task(); |
| + delete entry; |
| + return task; |
| +} |
| + |
| + |
| +void* ThreadPool::Main(void* args) { |
| + printf("Thread pool thread started\n"); |
|
Mads Ager (google)
2012/01/04 14:32:46
Should we remove this printing or add a --trace-th
Søren Gjesse
2012/01/04 15:15:07
Added flag --trace_thread_pool.
|
| + ThreadPool* pool = reinterpret_cast<ThreadPool*>(args); |
| + while (true) { |
| + printf("Waiting for task\n"); |
| + Task task = pool->WaitForTask(); |
| + printf("Got task %d\n", task); |
| + } |
| + return NULL; |
| +}; |