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

Unified Diff: runtime/bin/thread_pool.cc

Issue 9112013: Thread pool changes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added tread pool shutdown Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/thread_pool.h ('k') | runtime/bin/thread_pool_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/thread_pool.cc
diff --git a/runtime/bin/thread_pool.cc b/runtime/bin/thread_pool.cc
index 2a974e92d0d9bfa9bbb544e4d3cc277a114560ec..f8c26e87e010ee24712a271722ab554068ed3cca 100644
--- a/runtime/bin/thread_pool.cc
+++ b/runtime/bin/thread_pool.cc
@@ -4,21 +4,16 @@
#include "bin/thread_pool.h"
-void ThreadPool::Shutdown() {
- UNIMPLEMENTED();
-}
-
-
void ThreadPool::InsertTask(Task task) {
TaskQueueEntry* entry = new TaskQueueEntry(task);
- queue.Insert(entry);
+ queue_.Insert(entry);
}
Task ThreadPool::WaitForTask() {
- TaskQueueEntry* entry = queue.Remove();
+ TaskQueueEntry* entry = queue_.Remove();
if (entry == NULL) {
- return -1;
+ return NULL;
}
Task task = entry->task();
delete entry;
@@ -31,14 +26,13 @@ void* ThreadPool::Main(void* args) {
printf("Thread pool thread started\n");
}
ThreadPool* pool = reinterpret_cast<ThreadPool*>(args);
- while (true) {
+ while (!pool->terminate_) {
if (Dart_IsVMFlagSet("trace_thread_pool")) {
printf("Waiting for task\n");
}
Task task = pool->WaitForTask();
- if (Dart_IsVMFlagSet("trace_thread_pool")) {
- printf("Got task %d\n", task);
- }
+ if (pool->terminate_) return NULL;
+ (*(pool->task_handler_))(task);
}
return NULL;
};
« no previous file with comments | « runtime/bin/thread_pool.h ('k') | runtime/bin/thread_pool_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698