summaryrefslogtreecommitdiffstats
path: root/base/worker_pool_linux.cc
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-06 20:35:45 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-06 20:35:45 +0000
commit5846da03b8e2673d6be22f317a4eba89db9a03ed (patch)
treee732d84d13bd29d608f184f9d58671c4feed82e0 /base/worker_pool_linux.cc
parentea8395df79a1585f765946a002676cf2bf1c65c5 (diff)
downloadchromium_src-5846da03b8e2673d6be22f317a4eba89db9a03ed.zip
chromium_src-5846da03b8e2673d6be22f317a4eba89db9a03ed.tar.gz
chromium_src-5846da03b8e2673d6be22f317a4eba89db9a03ed.tar.bz2
In preparation for making changes to worker_pool_linux.cc.
Review URL: http://codereview.chromium.org/39081 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11149 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/worker_pool_linux.cc')
-rw-r--r--base/worker_pool_linux.cc42
1 files changed, 42 insertions, 0 deletions
diff --git a/base/worker_pool_linux.cc b/base/worker_pool_linux.cc
new file mode 100644
index 0000000..fce8861
--- /dev/null
+++ b/base/worker_pool_linux.cc
@@ -0,0 +1,42 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/worker_pool.h"
+
+#include "base/task.h"
+
+namespace {
+
+void* PThreadCallback(void* param) {
+ Task* task = static_cast<Task*>(param);
+ task->Run();
+ delete task;
+ return 0;
+}
+
+} // namespace
+
+bool WorkerPool::PostTask(const tracked_objects::Location& from_here,
+ Task* task, bool task_is_slow) {
+ task->SetBirthPlace(from_here);
+
+ pthread_t thread;
+ pthread_attr_t attr;
+
+ // POSIX does not have a worker thread pool implementation. For now we just
+ // create a thread for each task, and ignore |task_is_slow|.
+ // TODO(dsh): Implement thread reuse.
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+ int err = pthread_create(&thread, &attr, PThreadCallback, task);
+ pthread_attr_destroy(&attr);
+ if (err) {
+ DLOG(ERROR) << "pthread_create failed: " << err;
+ delete task;
+ return false;
+ }
+
+ return true;
+}