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

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

Issue 9231020: Use platform implementation of Monitor in thread pool (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « no previous file | runtime/bin/thread_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 11
11 // Declare the OS-specific types ahead of defining the generic classes. 12 // Declare the OS-specific types ahead of defining the generic classes.
12 #if defined(TARGET_OS_LINUX) 13 #if defined(TARGET_OS_LINUX)
13 #include "bin/thread_pool_linux.h" 14 #include "bin/thread_pool_linux.h"
14 #elif defined(TARGET_OS_MACOS) 15 #elif defined(TARGET_OS_MACOS)
15 #include "bin/thread_pool_macos.h" 16 #include "bin/thread_pool_macos.h"
16 #elif defined(TARGET_OS_WINDOWS) 17 #elif defined(TARGET_OS_WINDOWS)
17 #include "bin/thread_pool_win.h" 18 #include "bin/thread_pool_win.h"
18 #else 19 #else
19 #error Unknown target os. 20 #error Unknown target os.
(...skipping 16 matching lines...) Expand all
36 Task task_; 37 Task task_;
37 TaskQueueEntry* next_; 38 TaskQueueEntry* next_;
38 }; 39 };
39 40
40 41
41 // The task queue is a single linked list. Link direction is from tail 42 // The task queue is a single linked list. Link direction is from tail
42 // to head. New entried are inserted at the tail and entries are 43 // to head. New entried are inserted at the tail and entries are
43 // removed from the head. 44 // removed from the head.
44 class TaskQueue { 45 class TaskQueue {
45 public: 46 public:
46 TaskQueue(); 47 TaskQueue() : terminate_(false), head_(NULL), tail_(NULL) {}
47 48
48 void Insert(TaskQueueEntry* task); 49 void Insert(TaskQueueEntry* task);
49 TaskQueueEntry* Remove(); 50 TaskQueueEntry* Remove();
50 void Shutdown(); 51 void Shutdown();
51 52
52 private: 53 private:
53 bool terminate_; 54 bool terminate_;
54 TaskQueueEntry* head_; 55 TaskQueueEntry* head_;
55 TaskQueueEntry* tail_; 56 TaskQueueEntry* tail_;
56 TaskQueueData data_; 57 dart::Monitor monitor_;
57 58
58 DISALLOW_COPY_AND_ASSIGN(TaskQueue); 59 DISALLOW_COPY_AND_ASSIGN(TaskQueue);
59 }; 60 };
60 61
61 62
62 class ThreadPool { 63 class ThreadPool {
63 public: 64 public:
64 typedef void* (*TaskHandler)(void* args); 65 typedef void* (*TaskHandler)(void* args);
65 66
66 ThreadPool(TaskHandler task_handler, int initial_size = 4) 67 ThreadPool(TaskHandler task_handler, int initial_size = 4)
(...skipping 16 matching lines...) Expand all
83 // obtain it for updating terminate_. 84 // obtain it for updating terminate_.
84 bool terminate_; 85 bool terminate_;
85 int size_; // Number of threads. 86 int size_; // Number of threads.
86 TaskHandler task_handler_; 87 TaskHandler task_handler_;
87 ThreadPoolData data_; 88 ThreadPoolData data_;
88 89
89 DISALLOW_COPY_AND_ASSIGN(ThreadPool); 90 DISALLOW_COPY_AND_ASSIGN(ThreadPool);
90 }; 91 };
91 92
92 #endif // BIN_THREAD_POOL_H_ 93 #endif // BIN_THREAD_POOL_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/thread_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698