| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // Posts |task| with specific |traits| to the TaskScheduler and posts |reply| on | 79 // Posts |task| with specific |traits| to the TaskScheduler and posts |reply| on |
| 80 // the caller's execution context (i.e. same sequence or thread and same | 80 // the caller's execution context (i.e. same sequence or thread and same |
| 81 // TaskTraits if applicable) when |task| completes. Can only be called when | 81 // TaskTraits if applicable) when |task| completes. Can only be called when |
| 82 // SequencedTaskRunnerHandle::IsSet(). | 82 // SequencedTaskRunnerHandle::IsSet(). |
| 83 BASE_EXPORT void PostTaskWithTraitsAndReply( | 83 BASE_EXPORT void PostTaskWithTraitsAndReply( |
| 84 const tracked_objects::Location& from_here, | 84 const tracked_objects::Location& from_here, |
| 85 const TaskTraits& traits, | 85 const TaskTraits& traits, |
| 86 const Closure& task, | 86 const Closure& task, |
| 87 const Closure& reply); | 87 const Closure& reply); |
| 88 | 88 |
| 89 // Delayed tasks posted to TaskRunners returned by the functions below may be |
| 90 // coalesced (i.e. delays may be adjusted to reduce the number of wakeups and |
| 91 // hence power consumption). |
| 92 |
| 89 // Returns a TaskRunner whose PostTask invocations result in scheduling tasks | 93 // Returns a TaskRunner whose PostTask invocations result in scheduling tasks |
| 90 // using |traits|. Tasks may run in any order and in parallel. | 94 // using |traits|. Tasks may run in any order and in parallel. |
| 91 BASE_EXPORT scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits( | 95 BASE_EXPORT scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits( |
| 92 const TaskTraits& traits); | 96 const TaskTraits& traits); |
| 93 | 97 |
| 94 // Returns a SequencedTaskRunner whose PostTask invocations result in scheduling | 98 // Returns a SequencedTaskRunner whose PostTask invocations result in scheduling |
| 95 // tasks using |traits|. Tasks run one at a time in posting order. | 99 // tasks using |traits|. Tasks run one at a time in posting order. |
| 96 BASE_EXPORT scoped_refptr<SequencedTaskRunner> | 100 BASE_EXPORT scoped_refptr<SequencedTaskRunner> |
| 97 CreateSequencedTaskRunnerWithTraits(const TaskTraits& traits); | 101 CreateSequencedTaskRunnerWithTraits(const TaskTraits& traits); |
| 98 | 102 |
| 99 // Returns a SingleThreadTaskRunner whose PostTask invocations result in | 103 // Returns a SingleThreadTaskRunner whose PostTask invocations result in |
| 100 // scheduling tasks using |traits|. Tasks run on a single thread in posting | 104 // scheduling tasks using |traits|. Tasks run on a single thread in posting |
| 101 // order. | 105 // order. |
| 102 // | 106 // |
| 103 // If all you need is to make sure that tasks don't run concurrently (e.g. | 107 // If all you need is to make sure that tasks don't run concurrently (e.g. |
| 104 // because they access a data structure which is not thread-safe), use | 108 // because they access a data structure which is not thread-safe), use |
| 105 // CreateSequencedTaskRunnerWithTraits(). Only use this if you rely on a thread- | 109 // CreateSequencedTaskRunnerWithTraits(). Only use this if you rely on a thread- |
| 106 // affine API (it might be safer to assume thread-affinity when dealing with | 110 // affine API (it might be safer to assume thread-affinity when dealing with |
| 107 // under-documented third-party APIs, e.g. other OS') or share data across tasks | 111 // under-documented third-party APIs, e.g. other OS') or share data across tasks |
| 108 // using thread-local storage. | 112 // using thread-local storage. |
| 109 BASE_EXPORT scoped_refptr<SingleThreadTaskRunner> | 113 BASE_EXPORT scoped_refptr<SingleThreadTaskRunner> |
| 110 CreateSingleThreadTaskRunnerWithTraits(const TaskTraits& traits); | 114 CreateSingleThreadTaskRunnerWithTraits(const TaskTraits& traits); |
| 111 | 115 |
| 112 } // namespace base | 116 } // namespace base |
| 113 | 117 |
| 114 #endif // BASE_TASK_SCHEDULER_POST_TASK_H_ | 118 #endif // BASE_TASK_SCHEDULER_POST_TASK_H_ |
| OLD | NEW |