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

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

Issue 2122543002: Replace Closure in TaskRunner::PostTask with OneShotCallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@07_oneshot
Patch Set: fix Created 4 years, 3 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_forward.h" 9 #include "base/callback_forward.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 16 matching lines...) Expand all
27 // inside the pool must be extremely careful about other objects they access 27 // inside the pool must be extremely careful about other objects they access
28 // (MessageLoops, Singletons, etc). During shutdown these object may no longer 28 // (MessageLoops, Singletons, etc). During shutdown these object may no longer
29 // exist. 29 // exist.
30 class BASE_EXPORT WorkerPool { 30 class BASE_EXPORT WorkerPool {
31 public: 31 public:
32 // This function posts |task| to run on a worker thread. |task_is_slow| 32 // This function posts |task| to run on a worker thread. |task_is_slow|
33 // should be used for tasks that will take a long time to execute. Returns 33 // should be used for tasks that will take a long time to execute. Returns
34 // false if |task| could not be posted to a worker thread. Regardless of 34 // false if |task| could not be posted to a worker thread. Regardless of
35 // return value, ownership of |task| is transferred to the worker pool. 35 // return value, ownership of |task| is transferred to the worker pool.
36 static bool PostTask(const tracked_objects::Location& from_here, 36 static bool PostTask(const tracked_objects::Location& from_here,
37 const base::Closure& task, bool task_is_slow); 37 OnceClosure task,
38 bool task_is_slow);
38 39
39 // Just like TaskRunner::PostTaskAndReply, except the destination 40 // Just like TaskRunner::PostTaskAndReply, except the destination
40 // for |task| is a worker thread and you can specify |task_is_slow| just 41 // for |task| is a worker thread and you can specify |task_is_slow| just
41 // like you can for PostTask above. 42 // like you can for PostTask above.
42 static bool PostTaskAndReply(const tracked_objects::Location& from_here, 43 static bool PostTaskAndReply(const tracked_objects::Location& from_here,
43 const Closure& task, 44 OnceClosure task,
44 const Closure& reply, 45 OnceClosure reply,
45 bool task_is_slow); 46 bool task_is_slow);
46 47
47 // Return true if the current thread is one that this WorkerPool runs tasks 48 // Return true if the current thread is one that this WorkerPool runs tasks
48 // on. (Note that if the Windows worker pool is used without going through 49 // on. (Note that if the Windows worker pool is used without going through
49 // this WorkerPool interface, RunsTasksOnCurrentThread would return false on 50 // this WorkerPool interface, RunsTasksOnCurrentThread would return false on
50 // those threads.) 51 // those threads.)
51 static bool RunsTasksOnCurrentThread(); 52 static bool RunsTasksOnCurrentThread();
52 53
53 // Get a TaskRunner wrapper which posts to the WorkerPool using the given 54 // Get a TaskRunner wrapper which posts to the WorkerPool using the given
54 // |task_is_slow| behavior. 55 // |task_is_slow| behavior.
55 static const scoped_refptr<TaskRunner>& GetTaskRunner(bool task_is_slow); 56 static const scoped_refptr<TaskRunner>& GetTaskRunner(bool task_is_slow);
56 }; 57 };
57 58
58 } // namespace base 59 } // namespace base
59 60
60 #endif // BASE_THREADING_WORKER_POOL_H_ 61 #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