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