OLD | NEW |
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.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 | 11 |
12 namespace tracked_objects { | 12 namespace tracked_objects { |
13 class Location; | 13 class Location; |
14 } // namespace tracked_objects | 14 } // namespace tracked_objects |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 | 17 |
18 class TaskRunner; | 18 class TaskRunner; |
19 | 19 |
(...skipping 11 matching lines...) Expand all Loading... |
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 const base::Closure& task, bool task_is_slow); | 35 const base::Closure& task, bool task_is_slow); |
36 | 36 |
37 // Just like TaskRunner::PostTaskAndReply, except the destination | 37 // Just like TaskRunner::PostTaskAndReply, except the destination |
38 // for |task| is a worker thread and you can specify |task_is_slow| just | 38 // for |task| is a worker thread and you can specify |task_is_slow| just |
39 // like you can for PostTask above. | 39 // like you can for PostTask above. |
40 static bool PostTaskAndReply(const tracked_objects::Location& from_here, | 40 static bool PostTaskAndReply(const tracked_objects::Location& from_here, |
41 const Closure& task, | 41 Closure task, |
42 const Closure& reply, | 42 Closure reply, |
43 bool task_is_slow); | 43 bool task_is_slow); |
44 | 44 |
45 // Return true if the current thread is one that this WorkerPool runs tasks | 45 // Return true if the current thread is one that this WorkerPool runs tasks |
46 // on. (Note that if the Windows worker pool is used without going through | 46 // on. (Note that if the Windows worker pool is used without going through |
47 // this WorkerPool interface, RunsTasksOnCurrentThread would return false on | 47 // this WorkerPool interface, RunsTasksOnCurrentThread would return false on |
48 // those threads.) | 48 // those threads.) |
49 static bool RunsTasksOnCurrentThread(); | 49 static bool RunsTasksOnCurrentThread(); |
50 | 50 |
51 // Get a TaskRunner wrapper which posts to the WorkerPool using the given | 51 // Get a TaskRunner wrapper which posts to the WorkerPool using the given |
52 // |task_is_slow| behavior. | 52 // |task_is_slow| behavior. |
53 static const scoped_refptr<TaskRunner>& GetTaskRunner(bool task_is_slow); | 53 static const scoped_refptr<TaskRunner>& GetTaskRunner(bool task_is_slow); |
54 }; | 54 }; |
55 | 55 |
56 } // namespace base | 56 } // namespace base |
57 | 57 |
58 #endif // BASE_THREADING_WORKER_POOL_H_ | 58 #endif // BASE_THREADING_WORKER_POOL_H_ |
OLD | NEW |