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

Side by Side Diff: base/threading/worker_pool.h

Issue 7316015: Support Closure in ALL the loops! (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed nit and rebased. Created 9 years, 4 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 | « base/task.cc ('k') | base/threading/worker_pool_posix.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_THREADING_WORKER_POOL_H_ 5 #ifndef BASE_THREADING_WORKER_POOL_H_
6 #define BASE_THREADING_WORKER_POOL_H_ 6 #define BASE_THREADING_WORKER_POOL_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/base_api.h" 9 #include "base/base_api.h"
10 #include "base/callback.h"
10 #include "base/tracked.h" 11 #include "base/tracked.h"
11 12
12 class Task; 13 class Task;
13 14
14 namespace base { 15 namespace base {
15 16
16 // This is a facility that runs tasks that don't require a specific thread or 17 // This is a facility that runs tasks that don't require a specific thread or
17 // a message loop. 18 // a message loop.
18 // 19 //
19 // WARNING: This shouldn't be used unless absolutely necessary. We don't wait 20 // WARNING: This shouldn't be used unless absolutely necessary. We don't wait
20 // for the worker pool threads to finish on shutdown, so the tasks running 21 // for the worker pool threads to finish on shutdown, so the tasks running
21 // inside the pool must be extremely careful about other objects they access 22 // inside the pool must be extremely careful about other objects they access
22 // (MessageLoops, Singletons, etc). During shutdown these object may no longer 23 // (MessageLoops, Singletons, etc). During shutdown these object may no longer
23 // exist. 24 // exist.
24 class BASE_API WorkerPool { 25 class BASE_API WorkerPool {
25 public: 26 public:
26 // This function posts |task| to run on a worker thread. |task_is_slow| 27 // This function posts |task| to run on a worker thread. |task_is_slow|
27 // should be used for tasks that will take a long time to execute. Returns 28 // should be used for tasks that will take a long time to execute. Returns
28 // false if |task| could not be posted to a worker thread. Regardless of 29 // false if |task| could not be posted to a worker thread. Regardless of
29 // return value, ownership of |task| is transferred to the worker pool. 30 // return value, ownership of |task| is transferred to the worker pool.
31 //
32 // TODO(ajwong): Remove the Task* based overload once we've finishsed the
33 // Task -> Closure migration.
30 static bool PostTask(const tracked_objects::Location& from_here, 34 static bool PostTask(const tracked_objects::Location& from_here,
31 Task* task, bool task_is_slow); 35 Task* task, bool task_is_slow);
36 static bool PostTask(const tracked_objects::Location& from_here,
37 const base::Closure& task, bool task_is_slow);
32 }; 38 };
33 39
34 } // namespace base 40 } // namespace base
35 41
36 #endif // BASE_THREADING_WORKER_POOL_H_ 42 #endif // BASE_THREADING_WORKER_POOL_H_
OLDNEW
« no previous file with comments | « base/task.cc ('k') | base/threading/worker_pool_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698