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

Unified Diff: runtime/bin/thread_pool.cc

Issue 8983017: Start of thread pool implementation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from ager@ Created 8 years, 12 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
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..2a974e92d0d9bfa9bbb544e4d3cc277a114560ec
--- /dev/null
+++ b/runtime/bin/thread_pool.cc
@@ -0,0 +1,44 @@
+// 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) {
+ if (Dart_IsVMFlagSet("trace_thread_pool")) {
+ printf("Thread pool thread started\n");
+ }
+ ThreadPool* pool = reinterpret_cast<ThreadPool*>(args);
+ while (true) {
+ 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);
+ }
+ }
+ return NULL;
+};

Powered by Google App Engine
This is Rietveld 408576698