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

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: Fix compilation on Windows 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..381b608b5a2417a7288e3b918429aad3f6b03954
--- /dev/null
+++ b/runtime/bin/thread_pool.cc
@@ -0,0 +1,38 @@
+// 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) {
+ printf("Thread pool thread started\n");
Mads Ager (google) 2012/01/04 14:32:46 Should we remove this printing or add a --trace-th
Søren Gjesse 2012/01/04 15:15:07 Added flag --trace_thread_pool.
+ ThreadPool* pool = reinterpret_cast<ThreadPool*>(args);
+ while (true) {
+ printf("Waiting for task\n");
+ Task task = pool->WaitForTask();
+ printf("Got task %d\n", task);
+ }
+ return NULL;
+};

Powered by Google App Engine
This is Rietveld 408576698