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_TASK_SCHEDULER_H_ | 5 #ifndef BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ |
6 #define BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ | 6 #define BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // called once. | 75 // called once. |
76 virtual void Shutdown() = 0; | 76 virtual void Shutdown() = 0; |
77 | 77 |
78 // Waits until there are no pending undelayed tasks. May be called in tests | 78 // Waits until there are no pending undelayed tasks. May be called in tests |
79 // to validate that a condition is met after all undelayed tasks have run. | 79 // to validate that a condition is met after all undelayed tasks have run. |
80 // | 80 // |
81 // Does not wait for delayed tasks. Waits for undelayed tasks posted from | 81 // Does not wait for delayed tasks. Waits for undelayed tasks posted from |
82 // other threads during the call. Returns immediately when shutdown completes. | 82 // other threads during the call. Returns immediately when shutdown completes. |
83 virtual void FlushForTesting() = 0; | 83 virtual void FlushForTesting() = 0; |
84 | 84 |
85 // Joins all threads of this scheduler. Tasks that are already running are | |
86 // allowed to complete their execution. This can only be called once. | |
87 virtual void JoinForTesting() = 0; | |
88 | |
89 // CreateAndSetSimpleTaskScheduler(), CreateAndSetDefaultTaskScheduler(), and | 85 // CreateAndSetSimpleTaskScheduler(), CreateAndSetDefaultTaskScheduler(), and |
90 // SetInstance() register a TaskScheduler to handle tasks posted through the | 86 // SetInstance() register a TaskScheduler to handle tasks posted through the |
91 // post_task.h API for this process. The registered TaskScheduler will only be | 87 // post_task.h API for this process. The registered TaskScheduler will only be |
92 // deleted when a new TaskScheduler is registered and is leaked on shutdown. | 88 // deleted when a new TaskScheduler is registered and is leaked on shutdown. |
93 // The methods must not be called when TaskRunners created by the previous | 89 // The methods must not be called when TaskRunners created by the previous |
94 // TaskScheduler are still alive. The methods are not thread-safe; proper | 90 // TaskScheduler are still alive. The methods are not thread-safe; proper |
95 // synchronization is required to use the post_task.h API after registering a | 91 // synchronization is required to use the post_task.h API after registering a |
96 // new TaskScheduler. | 92 // new TaskScheduler. |
97 | 93 |
98 // Creates and sets a task scheduler with one worker pool that can have up to | 94 // Creates and sets a task scheduler with one worker pool that can have up to |
(...skipping 15 matching lines...) Expand all Loading... |
114 | 110 |
115 // Retrieve the TaskScheduler set via CreateAndSetDefaultTaskScheduler() or | 111 // Retrieve the TaskScheduler set via CreateAndSetDefaultTaskScheduler() or |
116 // SetInstance(). This should be used very rarely; most users of TaskScheduler | 112 // SetInstance(). This should be used very rarely; most users of TaskScheduler |
117 // should use the post_task.h API. | 113 // should use the post_task.h API. |
118 static TaskScheduler* GetInstance(); | 114 static TaskScheduler* GetInstance(); |
119 }; | 115 }; |
120 | 116 |
121 } // namespace base | 117 } // namespace base |
122 | 118 |
123 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ | 119 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ |
OLD | NEW |