Chromium Code Reviews| Index: base/task_scheduler/task_scheduler.h |
| diff --git a/base/task_scheduler/task_scheduler.h b/base/task_scheduler/task_scheduler.h |
| index 5d9344bcbad7e52502f645ce3001026621d1dbe2..a73929cc88938f50a223e934188820b463c8db6d 100644 |
| --- a/base/task_scheduler/task_scheduler.h |
| +++ b/base/task_scheduler/task_scheduler.h |
| @@ -38,6 +38,9 @@ class BASE_EXPORT TaskScheduler { |
| using WorkerPoolIndexForTraitsCallback = |
| Callback<size_t(const TaskTraits& traits)>; |
| + // Destroying a TaskScheduler is not allowed in production; it is always |
| + // leaked. In tests, it should only be destroyed after JoinForTesting() has |
| + // returned. |
|
gab
2017/01/17 21:24:25
ScopedTaskScheduler doesn't honor the second sente
fdoray
2017/01/17 23:51:00
Changed ScopedTaskScheduler. I don't want callers
gab
2017/01/18 00:28:13
sgtm
|
| virtual ~TaskScheduler() = default; |
| // Posts |task| with a |delay| and specific |traits|. |delay| can be zero. |
| @@ -85,6 +88,10 @@ class BASE_EXPORT TaskScheduler { |
| // other threads during the call. Returns immediately when shutdown completes. |
| virtual void FlushForTesting() = 0; |
| + // Joins all threads. Tasks that are already running are allowed to complete |
| + // their execution. This can only be called once. |
| + virtual void JoinForTesting() = 0; |
| + |
| // CreateAndSetSimpleTaskScheduler(), CreateAndSetDefaultTaskScheduler(), and |
| // SetInstance() register a TaskScheduler to handle tasks posted through the |
| // post_task.h API for this process. The registered TaskScheduler will only be |