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

Side by Side Diff: runtime/bin/thread_pool.h

Issue 9141005: Change the thread interface in runtime/platform and use it starting all threads (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r3454 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef BIN_THREAD_POOL_H_ 5 #ifndef BIN_THREAD_POOL_H_
6 #define BIN_THREAD_POOL_H_ 6 #define BIN_THREAD_POOL_H_
7 7
8 #include "bin/builtin.h" 8 #include "bin/builtin.h"
9 #include "platform/globals.h" 9 #include "platform/globals.h"
10 #include "platform/thread.h" 10 #include "platform/thread.h"
11 11
12 // Declare the OS-specific types ahead of defining the generic classes.
13 #if defined(TARGET_OS_LINUX)
14 #include "bin/thread_pool_linux.h"
15 #elif defined(TARGET_OS_MACOS)
16 #include "bin/thread_pool_macos.h"
17 #elif defined(TARGET_OS_WINDOWS)
18 #include "bin/thread_pool_win.h"
19 #else
20 #error Unknown target os.
21 #endif
22
23
24 typedef void* Task; 12 typedef void* Task;
25 13
26 14
27 class TaskQueueEntry { 15 class TaskQueueEntry {
28 public: 16 public:
29 explicit TaskQueueEntry(Task task) : task_(task), next_(NULL) {} 17 explicit TaskQueueEntry(Task task) : task_(task), next_(NULL) {}
30 18
31 Task task() { return task_; } 19 Task task() { return task_; }
32 20
33 TaskQueueEntry* next() { return next_; } 21 TaskQueueEntry* next() { return next_; }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 task_handler_(task_handler) {} 58 task_handler_(task_handler) {}
71 59
72 void Start(); 60 void Start();
73 void Shutdown(); 61 void Shutdown();
74 62
75 void InsertTask(Task task); 63 void InsertTask(Task task);
76 64
77 private: 65 private:
78 Task WaitForTask(); 66 Task WaitForTask();
79 67
80 static void* Main(void* args); 68 static void Main(uword);
Mads Ager (google) 2012/01/20 12:35:34 uword args?
Søren Gjesse 2012/01/20 13:25:45 Done.
81 69
82 TaskQueue queue_; 70 TaskQueue queue_;
83 // TODO(sgjesse): Move the monitor in TaskQueue to ThreadPool and 71 // TODO(sgjesse): Move the monitor in TaskQueue to ThreadPool and
84 // obtain it for updating terminate_. 72 // obtain it for updating terminate_.
85 bool terminate_; 73 bool terminate_;
86 int size_; // Number of threads. 74 int size_; // Number of threads.
87 TaskHandler task_handler_; 75 TaskHandler task_handler_;
88 ThreadPoolData data_; 76 dart::ThreadHandle* threads_;
89 77
90 DISALLOW_COPY_AND_ASSIGN(ThreadPool); 78 DISALLOW_COPY_AND_ASSIGN(ThreadPool);
91 }; 79 };
92 80
93 #endif // BIN_THREAD_POOL_H_ 81 #endif // BIN_THREAD_POOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698