Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(842)

Unified Diff: base/task_scheduler/task_scheduler.h

Issue 2628313004: Add TaskScheduler::JoinForTesting(). (Closed)
Patch Set: self-review Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/task_scheduler/scheduler_worker_pool_impl.h ('k') | base/task_scheduler/task_scheduler_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
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
« no previous file with comments | « base/task_scheduler/scheduler_worker_pool_impl.h ('k') | base/task_scheduler/task_scheduler_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698