OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_TASK_SCHEDULER_POST_TASK_H_ | 5 #ifndef BASE_TASK_SCHEDULER_POST_TASK_H_ |
6 #define BASE_TASK_SCHEDULER_POST_TASK_H_ | 6 #define BASE_TASK_SCHEDULER_POST_TASK_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/location.h" | 10 #include "base/location.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // (2) don't affect user interaction and/or visible elements, and | 52 // (2) don't affect user interaction and/or visible elements, and |
53 // (3) can either block shutdown or be skipped on shutdown | 53 // (3) can either block shutdown or be skipped on shutdown |
54 // (barring current TaskScheduler default). | 54 // (barring current TaskScheduler default). |
55 // If those loose requirements are sufficient for your task, use | 55 // If those loose requirements are sufficient for your task, use |
56 // PostTask[AndReply], otherwise override these with explicit traits via | 56 // PostTask[AndReply], otherwise override these with explicit traits via |
57 // PostTaskWithTraits[AndReply]. | 57 // PostTaskWithTraits[AndReply]. |
58 | 58 |
59 // Posts |task| to the TaskScheduler. Calling this is equivalent to calling | 59 // Posts |task| to the TaskScheduler. Calling this is equivalent to calling |
60 // PostTaskWithTraits with plain TaskTraits. | 60 // PostTaskWithTraits with plain TaskTraits. |
61 BASE_EXPORT void PostTask(const tracked_objects::Location& from_here, | 61 BASE_EXPORT void PostTask(const tracked_objects::Location& from_here, |
62 const Closure& task); | 62 OnceClosure task); |
63 | 63 |
64 // Posts |task| to the TaskScheduler and posts |reply| on the caller's execution | 64 // Posts |task| to the TaskScheduler and posts |reply| on the caller's execution |
65 // context (i.e. same sequence or thread and same TaskTraits if applicable) when | 65 // context (i.e. same sequence or thread and same TaskTraits if applicable) when |
66 // |task| completes. Calling this is equivalent to calling | 66 // |task| completes. Calling this is equivalent to calling |
67 // PostTaskWithTraitsAndReply with plain TaskTraits. Can only be called when | 67 // PostTaskWithTraitsAndReply with plain TaskTraits. Can only be called when |
68 // SequencedTaskRunnerHandle::IsSet(). | 68 // SequencedTaskRunnerHandle::IsSet(). |
69 BASE_EXPORT void PostTaskAndReply(const tracked_objects::Location& from_here, | 69 BASE_EXPORT void PostTaskAndReply(const tracked_objects::Location& from_here, |
70 const Closure& task, | 70 OnceClosure task, |
71 const Closure& reply); | 71 OnceClosure reply); |
72 | 72 |
73 // Posts |task| with specific |traits| to the TaskScheduler. | 73 // Posts |task| with specific |traits| to the TaskScheduler. |
74 BASE_EXPORT void PostTaskWithTraits(const tracked_objects::Location& from_here, | 74 BASE_EXPORT void PostTaskWithTraits(const tracked_objects::Location& from_here, |
75 TaskTraits traits, | 75 TaskTraits traits, |
76 const Closure& task); | 76 OnceClosure task); |
77 | 77 |
78 // Posts |task| with specific |traits| to the TaskScheduler and posts |reply| on | 78 // Posts |task| with specific |traits| to the TaskScheduler and posts |reply| on |
79 // the caller's execution context (i.e. same sequence or thread and same | 79 // the caller's execution context (i.e. same sequence or thread and same |
80 // TaskTraits if applicable) when |task| completes. Can only be called when | 80 // TaskTraits if applicable) when |task| completes. Can only be called when |
81 // SequencedTaskRunnerHandle::IsSet(). | 81 // SequencedTaskRunnerHandle::IsSet(). |
82 BASE_EXPORT void PostTaskWithTraitsAndReply( | 82 BASE_EXPORT void PostTaskWithTraitsAndReply( |
83 const tracked_objects::Location& from_here, | 83 const tracked_objects::Location& from_here, |
84 TaskTraits traits, | 84 TaskTraits traits, |
85 const Closure& task, | 85 OnceClosure task, |
86 const Closure& reply); | 86 OnceClosure reply); |
87 | 87 |
88 // Returns a TaskRunner whose PostTask invocations will result in scheduling | 88 // Returns a TaskRunner whose PostTask invocations will result in scheduling |
89 // tasks using |traits| which will be executed according to |execution_mode|. | 89 // tasks using |traits| which will be executed according to |execution_mode|. |
90 BASE_EXPORT scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits( | 90 BASE_EXPORT scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits( |
91 TaskTraits traits, | 91 TaskTraits traits, |
92 ExecutionMode execution_mode); | 92 ExecutionMode execution_mode); |
93 | 93 |
94 } // namespace base | 94 } // namespace base |
95 | 95 |
96 #endif // BASE_TASK_SCHEDULER_POST_TASK_H_ | 96 #endif // BASE_TASK_SCHEDULER_POST_TASK_H_ |
OLD | NEW |