diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-30 18:08:36 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-30 18:08:36 +0000 |
commit | ac9ba8fe1d2f2397de3d7c4cebfb3c659d226fd3 (patch) | |
tree | 7118143b15fb701d5d91de270a1af7ea431eaa8a /base/threading/worker_pool.h | |
parent | b8eeb3eeba2418d9a1a7bb8429ddd5ec592298c1 (diff) | |
download | chromium_src-ac9ba8fe1d2f2397de3d7c4cebfb3c659d226fd3.zip chromium_src-ac9ba8fe1d2f2397de3d7c4cebfb3c659d226fd3.tar.gz chromium_src-ac9ba8fe1d2f2397de3d7c4cebfb3c659d226fd3.tar.bz2 |
Move some misc thread-related stuff from base to base/thread and into the base
namespace. This does not move the "hard" thread stuff (thread.h).
TEST=it compiles
BUG=none
Review URL: http://codereview.chromium.org/6079009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70315 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/threading/worker_pool.h')
-rw-r--r-- | base/threading/worker_pool.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/base/threading/worker_pool.h b/base/threading/worker_pool.h new file mode 100644 index 0000000..9a02acc --- /dev/null +++ b/base/threading/worker_pool.h @@ -0,0 +1,35 @@ +// Copyright (c) 2010 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. + +#ifndef BASE_THREADING_WORKER_POOL_H_ +#define BASE_THREADING_WORKER_POOL_H_ +#pragma once + +#include "base/tracked.h" + +class Task; + +namespace base { + +// This is a facility that runs tasks that don't require a specific thread or +// a message loop. +// +// WARNING: This shouldn't be used unless absolutely necessary. We don't wait +// for the worker pool threads to finish on shutdown, so the tasks running +// inside the pool must be extremely careful about other objects they access +// (MessageLoops, Singletons, etc). During shutdown these object may no longer +// exist. +class WorkerPool { + public: + // This function posts |task| to run on a worker thread. |task_is_slow| + // should be used for tasks that will take a long time to execute. Returns + // false if |task| could not be posted to a worker thread. Regardless of + // return value, ownership of |task| is transferred to the worker pool. + static bool PostTask(const tracked_objects::Location& from_here, + Task* task, bool task_is_slow); +}; + +} // namespace base + +#endif // BASE_THREADING_WORKER_POOL_H_ |