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

Unified Diff: runtime/bin/thread_pool.h

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/main.cc ('k') | runtime/bin/thread_pool.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/thread_pool.h
diff --git a/runtime/bin/thread_pool.h b/runtime/bin/thread_pool.h
index 75324375d5e630917072e60212205962fa38430a..8dfdda611dd6211505fba1f93ee02233d20515fb 100644
--- a/runtime/bin/thread_pool.h
+++ b/runtime/bin/thread_pool.h
@@ -21,7 +21,7 @@
#endif
-typedef int Task;
+typedef void* Task;
class TaskQueueEntry {
@@ -48,8 +48,10 @@ class TaskQueue {
void Insert(TaskQueueEntry* task);
TaskQueueEntry* Remove();
+ void Shutdown();
private:
+ bool terminate_;
TaskQueueEntry* head_;
TaskQueueEntry* tail_;
TaskQueueData data_;
@@ -60,7 +62,12 @@ class TaskQueue {
class ThreadPool {
public:
- explicit ThreadPool(int initial_size = 4) : size_(initial_size) {}
+ typedef void* (*TaskHandler)(void* args);
+
+ ThreadPool(TaskHandler task_handler, int initial_size = 4)
+ : terminate_(false),
+ size_(initial_size),
+ task_handler_(task_handler) {}
void Start();
void Shutdown();
@@ -72,8 +79,12 @@ class ThreadPool {
static void* Main(void* args);
- TaskQueue queue;
+ TaskQueue queue_;
+ // TODO(sgjesse): Move the monitor in TaskQueue to ThreadPool and
+ // obtain it for updating terminate_.
+ bool terminate_;
int size_; // Number of threads.
+ TaskHandler task_handler_;
ThreadPoolData data_;
DISALLOW_COPY_AND_ASSIGN(ThreadPool);
« no previous file with comments | « runtime/bin/main.cc ('k') | runtime/bin/thread_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698