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

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

Issue 2637843002: Migrate base::TaskRunner from Closure to OnceClosure (Closed)
Patch Set: rebase Created 3 years, 8 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
« no previous file with comments | « base/threading/sequenced_worker_pool.cc ('k') | base/threading/worker_pool.cc » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 14 matching lines...) Expand all
25 // inside the pool must be extremely careful about other objects they access 25 // inside the pool must be extremely careful about other objects they access
26 // (MessageLoops, Singletons, etc). During shutdown these object may no longer 26 // (MessageLoops, Singletons, etc). During shutdown these object may no longer
27 // exist. 27 // exist.
28 class BASE_EXPORT WorkerPool { 28 class BASE_EXPORT WorkerPool {
29 public: 29 public:
30 // This function posts |task| to run on a worker thread. |task_is_slow| 30 // This function posts |task| to run on a worker thread. |task_is_slow|
31 // should be used for tasks that will take a long time to execute. Returns 31 // should be used for tasks that will take a long time to execute. Returns
32 // false if |task| could not be posted to a worker thread. Regardless of 32 // false if |task| could not be posted to a worker thread. Regardless of
33 // return value, ownership of |task| is transferred to the worker pool. 33 // return value, ownership of |task| is transferred to the worker pool.
34 static bool PostTask(const tracked_objects::Location& from_here, 34 static bool PostTask(const tracked_objects::Location& from_here,
35 Closure task, 35 OnceClosure task,
36 bool task_is_slow); 36 bool task_is_slow);
37 37
38 // Just like TaskRunner::PostTaskAndReply, except the destination 38 // Just like TaskRunner::PostTaskAndReply, except the destination
39 // for |task| is a worker thread and you can specify |task_is_slow| just 39 // for |task| is a worker thread and you can specify |task_is_slow| just
40 // like you can for PostTask above. 40 // like you can for PostTask above.
41 static bool PostTaskAndReply(const tracked_objects::Location& from_here, 41 static bool PostTaskAndReply(const tracked_objects::Location& from_here,
42 Closure task, 42 OnceClosure task,
43 Closure reply, 43 OnceClosure reply,
44 bool task_is_slow); 44 bool task_is_slow);
45 45
46 // Return true if the current thread is one that this WorkerPool runs tasks 46 // Return true if the current thread is one that this WorkerPool runs tasks
47 // on. (Note that if the Windows worker pool is used without going through 47 // on. (Note that if the Windows worker pool is used without going through
48 // this WorkerPool interface, RunsTasksOnCurrentThread would return false on 48 // this WorkerPool interface, RunsTasksOnCurrentThread would return false on
49 // those threads.) 49 // those threads.)
50 static bool RunsTasksOnCurrentThread(); 50 static bool RunsTasksOnCurrentThread();
51 51
52 // Get a TaskRunner wrapper which posts to the WorkerPool using the given 52 // Get a TaskRunner wrapper which posts to the WorkerPool using the given
53 // |task_is_slow| behavior. 53 // |task_is_slow| behavior.
54 static const scoped_refptr<TaskRunner>& GetTaskRunner(bool task_is_slow); 54 static const scoped_refptr<TaskRunner>& GetTaskRunner(bool task_is_slow);
55 }; 55 };
56 56
57 } // namespace base 57 } // namespace base
58 58
59 #endif // BASE_THREADING_WORKER_POOL_H_ 59 #endif // BASE_THREADING_WORKER_POOL_H_
OLDNEW
« no previous file with comments | « base/threading/sequenced_worker_pool.cc ('k') | base/threading/worker_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698