| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // FROM_HERE, | 34 // FROM_HERE, |
| 35 // TaskTraits().WithPriority(TaskPriority::USER_BLOCKING), | 35 // TaskTraits().WithPriority(TaskPriority::USER_BLOCKING), |
| 36 // Bind(...)); | 36 // Bind(...)); |
| 37 // | 37 // |
| 38 // To post tasks that must run in sequence: | 38 // To post tasks that must run in sequence: |
| 39 // scoped_refptr<SequencedTaskRunner> task_runner = | 39 // scoped_refptr<SequencedTaskRunner> task_runner = |
| 40 // CreateSequencedTaskRunnerWithTraits(TaskTraits()); | 40 // CreateSequencedTaskRunnerWithTraits(TaskTraits()); |
| 41 // task_runner.PostTask(FROM_HERE, Bind(...)); | 41 // task_runner.PostTask(FROM_HERE, Bind(...)); |
| 42 // task_runner.PostTask(FROM_HERE, Bind(...)); | 42 // task_runner.PostTask(FROM_HERE, Bind(...)); |
| 43 // | 43 // |
| 44 // To post file I/O tasks that must run in sequence and can be skipped on | 44 // To post tasks that may block, must run in sequence and can be skipped on |
| 45 // shutdown: | 45 // shutdown: |
| 46 // scoped_refptr<SequencedTaskRunner> task_runner = | 46 // scoped_refptr<SequencedTaskRunner> task_runner = |
| 47 // CreateSequencedTaskRunnerWithTraits( | 47 // CreateSequencedTaskRunnerWithTraits( |
| 48 // TaskTraits().WithFileIO().WithShutdownBehavior( | 48 // TaskTraits().MayBlock().WithShutdownBehavior( |
| 49 // TaskShutdownBehavior::SKIP_ON_SHUTDOWN)); | 49 // TaskShutdownBehavior::SKIP_ON_SHUTDOWN)); |
| 50 // task_runner.PostTask(FROM_HERE, Bind(...)); | 50 // task_runner.PostTask(FROM_HERE, Bind(...)); |
| 51 // task_runner.PostTask(FROM_HERE, Bind(...)); | 51 // task_runner.PostTask(FROM_HERE, Bind(...)); |
| 52 // | 52 // |
| 53 // The default TaskTraits apply to tasks that: | 53 // The default TaskTraits apply to tasks that: |
| 54 // (1) don't need to do I/O, | 54 // (1) don't need to do I/O, |
| 55 // (2) don't affect user interaction and/or visible elements, and | 55 // (2) don't affect user interaction and/or visible elements, and |
| 56 // (3) can either block shutdown or be skipped on shutdown | 56 // (3) can either block shutdown or be skipped on shutdown |
| 57 // (barring current TaskScheduler default). | 57 // (barring current TaskScheduler default). |
| 58 // If those loose requirements are sufficient for your task, use | 58 // If those loose requirements are sufficient for your task, use |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // CreateSequencedTaskRunnerWithTraits(). Only use this if you rely on a thread- | 141 // CreateSequencedTaskRunnerWithTraits(). Only use this if you rely on a thread- |
| 142 // affine API (it might be safer to assume thread-affinity when dealing with | 142 // affine API (it might be safer to assume thread-affinity when dealing with |
| 143 // under-documented third-party APIs, e.g. other OS') or share data across tasks | 143 // under-documented third-party APIs, e.g. other OS') or share data across tasks |
| 144 // using thread-local storage. | 144 // using thread-local storage. |
| 145 BASE_EXPORT scoped_refptr<SingleThreadTaskRunner> | 145 BASE_EXPORT scoped_refptr<SingleThreadTaskRunner> |
| 146 CreateSingleThreadTaskRunnerWithTraits(const TaskTraits& traits); | 146 CreateSingleThreadTaskRunnerWithTraits(const TaskTraits& traits); |
| 147 | 147 |
| 148 } // namespace base | 148 } // namespace base |
| 149 | 149 |
| 150 #endif // BASE_TASK_SCHEDULER_POST_TASK_H_ | 150 #endif // BASE_TASK_SCHEDULER_POST_TASK_H_ |
| OLD | NEW |