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 |
85 // CreateAndSetDefaultTaskScheduler() and SetInstance() register a | 89 // CreateAndSetDefaultTaskScheduler() and SetInstance() register a |
86 // TaskScheduler to handle tasks posted through the post_task.h API for this | 90 // TaskScheduler to handle tasks posted through the post_task.h API for this |
87 // process. The registered TaskScheduler will only be deleted when a new | 91 // process. The registered TaskScheduler will only be deleted when a new |
88 // TaskScheduler is registered and is leaked on shutdown. The methods must | 92 // TaskScheduler is registered and is leaked on shutdown. The methods must |
89 // not be called when TaskRunners created by the previous TaskScheduler are | 93 // not be called when TaskRunners created by the previous TaskScheduler are |
90 // still alive. The methods are not thread-safe; proper synchronization is | 94 // still alive. The methods are not thread-safe; proper synchronization is |
91 // required to use the post_task.h API after registering a new TaskScheduler. | 95 // required to use the post_task.h API after registering a new TaskScheduler. |
92 | 96 |
93 // Creates and sets a default task scheduler. CHECKs on failure. | 97 // Creates and sets a default task scheduler. CHECKs on failure. |
94 // |worker_pool_params_vector| describes the worker pools to create. | 98 // |worker_pool_params_vector| describes the worker pools to create. |
(...skipping 10 matching lines...) Expand all Loading... |
105 | 109 |
106 // Retrieve the TaskScheduler set via CreateAndSetDefaultTaskScheduler() or | 110 // Retrieve the TaskScheduler set via CreateAndSetDefaultTaskScheduler() or |
107 // SetInstance(). This should be used very rarely; most users of TaskScheduler | 111 // SetInstance(). This should be used very rarely; most users of TaskScheduler |
108 // should use the post_task.h API. | 112 // should use the post_task.h API. |
109 static TaskScheduler* GetInstance(); | 113 static TaskScheduler* GetInstance(); |
110 }; | 114 }; |
111 | 115 |
112 } // namespace base | 116 } // namespace base |
113 | 117 |
114 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ | 118 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ |
OLD | NEW |