| 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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 namespace base { | 23 namespace base { |
| 24 | 24 |
| 25 // This is the preferred interface to post tasks to the TaskScheduler. | 25 // This is the preferred interface to post tasks to the TaskScheduler. |
| 26 // | 26 // |
| 27 // To post a simple one-off task with default traits: | 27 // To post a simple one-off task with default traits: |
| 28 // PostTask(FROM_HERE, Bind(...)); | 28 // PostTask(FROM_HERE, Bind(...)); |
| 29 // | 29 // |
| 30 // 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: |
| 31 // PostTaskWithTraits( | 31 // PostTaskWithTraits( |
| 32 // FROM_HERE, | 32 // FROM_HERE, |
| 33 // TaskTraits().WithPriority(TaskPriority::USER_BLOCKING), | 33 // {TaskPriority::USER_BLOCKING}, |
| 34 // Bind(...)); | 34 // Bind(...)); |
| 35 // | 35 // |
| 36 // To post tasks that must run in sequence with default traits: | 36 // To post tasks that must run in sequence with default traits: |
| 37 // scoped_refptr<SequencedTaskRunner> task_runner = | 37 // scoped_refptr<SequencedTaskRunner> task_runner = |
| 38 // CreateSequencedTaskRunnerWithTraits(TaskTraits()); | 38 // CreateSequencedTaskRunnerWithTraits(TaskTraits()); |
| 39 // task_runner.PostTask(FROM_HERE, Bind(...)); | 39 // task_runner.PostTask(FROM_HERE, Bind(...)); |
| 40 // task_runner.PostTask(FROM_HERE, Bind(...)); | 40 // task_runner.PostTask(FROM_HERE, Bind(...)); |
| 41 // | 41 // |
| 42 // To post tasks that may block, must run in sequence and can be skipped on | 42 // To post tasks that may block, must run in sequence and can be skipped on |
| 43 // shutdown: | 43 // shutdown: |
| 44 // scoped_refptr<SequencedTaskRunner> task_runner = | 44 // scoped_refptr<SequencedTaskRunner> task_runner = |
| 45 // CreateSequencedTaskRunnerWithTraits( | 45 // CreateSequencedTaskRunnerWithTraits( |
| 46 // TaskTraits().MayBlock().WithShutdownBehavior( | 46 // {MayBlock(), TaskShutdownBehavior::SKIP_ON_SHUTDOWN}); |
| 47 // TaskShutdownBehavior::SKIP_ON_SHUTDOWN)); | |
| 48 // task_runner.PostTask(FROM_HERE, Bind(...)); | 47 // task_runner.PostTask(FROM_HERE, Bind(...)); |
| 49 // task_runner.PostTask(FROM_HERE, Bind(...)); | 48 // task_runner.PostTask(FROM_HERE, Bind(...)); |
| 50 // | 49 // |
| 51 // The default traits apply to tasks that: | 50 // The default traits apply to tasks that: |
| 52 // (1) don't block (ref. MayBlock() and WithBaseSyncPrimitives()), | 51 // (1) don't block (ref. MayBlock() and WithBaseSyncPrimitives()), |
| 53 // (2) prefer inheriting the current priority to specifying their own, and | 52 // (2) prefer inheriting the current priority to specifying their own, and |
| 54 // (3) can either block shutdown or be skipped on shutdown | 53 // (3) can either block shutdown or be skipped on shutdown |
| 55 // (TaskScheduler implementation is free to choose a fitting default). | 54 // (TaskScheduler implementation is free to choose a fitting default). |
| 56 // Explicit traits must be specified for tasks for which these loose | 55 // Explicit traits must be specified for tasks for which these loose |
| 57 // requirements are not sufficient. | 56 // requirements are not sufficient. |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // implementation is free to share apartments or create new apartments as | 211 // implementation is free to share apartments or create new apartments as |
| 213 // necessary. In either case, care should be taken to make sure COM pointers are | 212 // necessary. In either case, care should be taken to make sure COM pointers are |
| 214 // not smuggled across apartments. | 213 // not smuggled across apartments. |
| 215 BASE_EXPORT scoped_refptr<SingleThreadTaskRunner> | 214 BASE_EXPORT scoped_refptr<SingleThreadTaskRunner> |
| 216 CreateCOMSTATaskRunnerWithTraits(const TaskTraits& traits); | 215 CreateCOMSTATaskRunnerWithTraits(const TaskTraits& traits); |
| 217 #endif // defined(OS_WIN) | 216 #endif // defined(OS_WIN) |
| 218 | 217 |
| 219 } // namespace base | 218 } // namespace base |
| 220 | 219 |
| 221 #endif // BASE_TASK_SCHEDULER_POST_TASK_H_ | 220 #endif // BASE_TASK_SCHEDULER_POST_TASK_H_ |
| OLD | NEW |