OLD | NEW |
1 # TaskScheduler Migration | 1 # TaskScheduler Migration |
2 | 2 |
3 [TOC] | 3 [TOC] |
4 | 4 |
5 ## Overview | 5 ## Overview |
6 | 6 |
7 [`base/task_scheduler/post_task.h`](https://cs.chromium.org/chromium/src/base/ta
sk_scheduler/post_task.h) | 7 [`base/task_scheduler/post_task.h`](https://cs.chromium.org/chromium/src/base/ta
sk_scheduler/post_task.h) |
8 was introduced to Chrome in Q1. The API is fully documented under [Threading and | 8 was introduced to Chrome in Q1. The API is fully documented under [Threading and |
9 Tasks in Chrome](threading_and_tasks.md). This page will go into more details | 9 Tasks in Chrome](threading_and_tasks.md). This page will go into more details |
10 about how to migrate callers of existing APIs to TaskScheduler. | 10 about how to migrate callers of existing APIs to TaskScheduler. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 decided otherwise by a developer. | 74 decided otherwise by a developer. |
75 | 75 |
76 As a developer your goal is to get rid of all uses of BrowserThread::FOO in your | 76 As a developer your goal is to get rid of all uses of BrowserThread::FOO in your |
77 assigned files by: | 77 assigned files by: |
78 1. Splitting things into their own execution sequence (i.e. post to a TaskRunne
r | 78 1. Splitting things into their own execution sequence (i.e. post to a TaskRunne
r |
79 obtained from post_task.h -- see [Threading and Tasks in | 79 obtained from post_task.h -- see [Threading and Tasks in |
80 Chrome](threading_and_tasks.md) for details). | 80 Chrome](threading_and_tasks.md) for details). |
81 2. Removing the plumbing: if GetTaskRunnerForThread(BrowserThread::FOO) is | 81 2. Removing the plumbing: if GetTaskRunnerForThread(BrowserThread::FOO) is |
82 passed down into a component the prefered paradigm is to remove all of that | 82 passed down into a component the prefered paradigm is to remove all of that |
83 plumbing and simply have the leaf layers requiring a TaskRunner get it from | 83 plumbing and simply have the leaf layers requiring a TaskRunner get it from |
84 base::CreateSequenceTaskRunnerWithTraits() directly. | 84 base::CreateSequencedTaskRunnerWithTraits() directly. |
85 3. Ideally migrating from a single-threaded context to a | 85 3. Ideally migrating from a single-threaded context to a |
86 [much preferred](threading_and_tasks.md#Prefer-Sequences-to-Threads) sequenc
ed context. | 86 [much preferred](threading_and_tasks.md#Prefer-Sequences-to-Threads) sequenc
ed context. |
87 * Note: if your tasks use COM APIs (Component Object Model on Windows), | 87 * Note: if your tasks use COM APIs (Component Object Model on Windows), |
88 you'll need to use CreateCOMSTATaskRunnerWithTraits() and sequencing will | 88 you'll need to use CreateCOMSTATaskRunnerWithTraits() and sequencing will |
89 not be an option (there are DCHECKs in place that will fire if your task | 89 not be an option (there are DCHECKs in place that will fire if your task |
90 uses COM without being on a COM initialized TaskRunner). | 90 uses COM without being on a COM initialized TaskRunner). |
91 | 91 |
92 ## Relevant single-thread -> sequence mappings | 92 ## Relevant single-thread -> sequence mappings |
93 | 93 |
94 * base::SingleThreadTaskRunner -> base::SequencedTaskRunner | 94 * base::SingleThreadTaskRunner -> base::SequencedTaskRunner |
(...skipping 28 matching lines...) Expand all Loading... |
123 * Everything in a file/component needs to run on the same sequence but there | 123 * Everything in a file/component needs to run on the same sequence but there |
124 isn't a clear place to own/access the common SequencedTaskRunner => | 124 isn't a clear place to own/access the common SequencedTaskRunner => |
125 base::Lazy(Sequenced|SingleThread|COMSTA)TaskRunner. | 125 base::Lazy(Sequenced|SingleThread|COMSTA)TaskRunner. |
126 * Mojo isn't sequence-friendly yet ([coming soon](https://crbug.com/678155)). | 126 * Mojo isn't sequence-friendly yet ([coming soon](https://crbug.com/678155)). |
127 Use base::CreateSingleThreadTaskRunnerWithTraits() instead of | 127 Use base::CreateSingleThreadTaskRunnerWithTraits() instead of |
128 base::CreateSequencedTaskRunnerWithTraits() for sequences that need to use | 128 base::CreateSequencedTaskRunnerWithTraits() for sequences that need to use |
129 mojo constructs for now (tag with TODO against https://crbug.com/678155). | 129 mojo constructs for now (tag with TODO against https://crbug.com/678155). |
130 * For anything else, ping [base/task_scheduler/OWNERS](https://cs.chromium.org/c
hromium/src/base/task_scheduler/OWNERS) | 130 * For anything else, ping [base/task_scheduler/OWNERS](https://cs.chromium.org/c
hromium/src/base/task_scheduler/OWNERS) |
131 or [scheduler-dev@chromium.org](https://groups.google.com/a/chromium.org/forum
/#!forum/scheduler-dev), | 131 or [scheduler-dev@chromium.org](https://groups.google.com/a/chromium.org/forum
/#!forum/scheduler-dev), |
132 thanks! | 132 thanks! |
OLD | NEW |