| 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 <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/post_task_and_reply_with_result_internal.h" | 15 #include "base/post_task_and_reply_with_result_internal.h" |
| 16 #include "base/sequenced_task_runner.h" | 16 #include "base/sequenced_task_runner.h" |
| 17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 18 #include "base/task_runner.h" | 18 #include "base/task_runner.h" |
| 19 #include "base/task_scheduler/task_traits.h" | 19 #include "base/task_scheduler/task_traits.h" |
| 20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "build/build_config.h" |
| 21 | 22 |
| 22 namespace base { | 23 namespace base { |
| 23 | 24 |
| 24 // This is the preferred interface to post tasks to the TaskScheduler. | 25 // This is the preferred interface to post tasks to the TaskScheduler. |
| 25 // | 26 // |
| 26 // To post a simple one-off task with default traits: | 27 // To post a simple one-off task with default traits: |
| 27 // PostTask(FROM_HERE, Bind(...)); | 28 // PostTask(FROM_HERE, Bind(...)); |
| 28 // | 29 // |
| 29 // To post a high priority one-off task to respond to a user interaction: | 30 // To post a high priority one-off task to respond to a user interaction: |
| 30 // PostTaskWithTraits( | 31 // PostTaskWithTraits( |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 // | 165 // |
| 165 // If all you need is to make sure that tasks don't run concurrently (e.g. | 166 // If all you need is to make sure that tasks don't run concurrently (e.g. |
| 166 // because they access a data structure which is not thread-safe), use | 167 // because they access a data structure which is not thread-safe), use |
| 167 // CreateSequencedTaskRunnerWithTraits(). Only use this if you rely on a thread- | 168 // CreateSequencedTaskRunnerWithTraits(). Only use this if you rely on a thread- |
| 168 // affine API (it might be safer to assume thread-affinity when dealing with | 169 // affine API (it might be safer to assume thread-affinity when dealing with |
| 169 // under-documented third-party APIs, e.g. other OS') or share data across tasks | 170 // under-documented third-party APIs, e.g. other OS') or share data across tasks |
| 170 // using thread-local storage. | 171 // using thread-local storage. |
| 171 BASE_EXPORT scoped_refptr<SingleThreadTaskRunner> | 172 BASE_EXPORT scoped_refptr<SingleThreadTaskRunner> |
| 172 CreateSingleThreadTaskRunnerWithTraits(const TaskTraits& traits); | 173 CreateSingleThreadTaskRunnerWithTraits(const TaskTraits& traits); |
| 173 | 174 |
| 175 #if defined(OS_WIN) |
| 176 // Returns a SingleThreadTaskRunner whose PostTask invocations result in |
| 177 // scheduling tasks using |traits| in a COM Single-Threaded Apartment. Tasks run |
| 178 // in the same Single-Threaded Apartment in posting order for the returned |
| 179 // SingleThreadTaskRunner. There is not necessarily a one-to-one correspondence |
| 180 // between SingleThreadTaskRunners and Single-Threaded Apartments. The |
| 181 // implementation is free to share apartments or create new apartments as |
| 182 // necessary. In either case, care should be taken to make sure COM pointers are |
| 183 // not smuggled across apartments. |
| 184 BASE_EXPORT scoped_refptr<SingleThreadTaskRunner> |
| 185 CreateCOMSTATaskRunnerWithTraits(const TaskTraits& traits); |
| 186 #endif // defined(OS_WIN) |
| 187 |
| 174 } // namespace base | 188 } // namespace base |
| 175 | 189 |
| 176 #endif // BASE_TASK_SCHEDULER_POST_TASK_H_ | 190 #endif // BASE_TASK_SCHEDULER_POST_TASK_H_ |
| OLD | NEW |