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

Side by Side Diff: base/task_scheduler/task_scheduler.h

Issue 2362253002: TaskScheduler: Add FlushForTesting(). (Closed)
Patch Set: fix build error Created 4 years, 2 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 unified diff | Download patch
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // posted with the BLOCK_SHUTDOWN behavior will be run. When this returns: 52 // posted with the BLOCK_SHUTDOWN behavior will be run. When this returns:
53 // - All SKIP_ON_SHUTDOWN tasks that were already running have completed their 53 // - All SKIP_ON_SHUTDOWN tasks that were already running have completed their
54 // execution. 54 // execution.
55 // - All posted BLOCK_SHUTDOWN tasks have completed their execution. 55 // - All posted BLOCK_SHUTDOWN tasks have completed their execution.
56 // - CONTINUE_ON_SHUTDOWN tasks might still be running. 56 // - CONTINUE_ON_SHUTDOWN tasks might still be running.
57 // Note that an implementation can keep threads and other resources alive to 57 // Note that an implementation can keep threads and other resources alive to
58 // support running CONTINUE_ON_SHUTDOWN after this returns. This can only be 58 // support running CONTINUE_ON_SHUTDOWN after this returns. This can only be
59 // called once. 59 // called once.
60 virtual void Shutdown() = 0; 60 virtual void Shutdown() = 0;
61 61
62 // Waits until there are no pending undelayed tasks. May be called in tests
63 // to validate that a condition is met after all undelayed tasks have run.
64 //
65 // Does not wait for delayed tasks. Waits for undelayed tasks posted from
66 // other threads during the call. Returns immediately when shutdown completes.
67 virtual void FlushForTesting() = 0;
68
62 // CreateAndSetDefaultTaskScheduler() and SetInstance() register a 69 // CreateAndSetDefaultTaskScheduler() and SetInstance() register a
63 // TaskScheduler to handle tasks posted through the post_task.h API for this 70 // TaskScheduler to handle tasks posted through the post_task.h API for this
64 // process. The registered TaskScheduler will only be deleted when a new 71 // process. The registered TaskScheduler will only be deleted when a new
65 // TaskScheduler is registered and is leaked on shutdown. The methods must 72 // TaskScheduler is registered and is leaked on shutdown. The methods must
66 // not be called when TaskRunners created by the previous TaskScheduler are 73 // not be called when TaskRunners created by the previous TaskScheduler are
67 // still alive. The methods are not thread-safe; proper synchronization is 74 // still alive. The methods are not thread-safe; proper synchronization is
68 // required to use the post_task.h API after registering a new TaskScheduler. 75 // required to use the post_task.h API after registering a new TaskScheduler.
69 76
70 // Creates and sets a default task scheduler. CHECKs on failure. 77 // Creates and sets a default task scheduler. CHECKs on failure.
71 // |worker_pool_params_vector| describes the worker pools to create. 78 // |worker_pool_params_vector| describes the worker pools to create.
(...skipping 10 matching lines...) Expand all
82 89
83 // Retrieve the TaskScheduler set via CreateAndSetDefaultTaskScheduler() or 90 // Retrieve the TaskScheduler set via CreateAndSetDefaultTaskScheduler() or
84 // SetInstance(). This should be used very rarely; most users of TaskScheduler 91 // SetInstance(). This should be used very rarely; most users of TaskScheduler
85 // should use the post_task.h API. 92 // should use the post_task.h API.
86 static TaskScheduler* GetInstance(); 93 static TaskScheduler* GetInstance();
87 }; 94 };
88 95
89 } // namespace base 96 } // namespace base
90 97
91 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ 98 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_
OLDNEW
« no previous file with comments | « base/task_scheduler/scheduler_worker_unittest.cc ('k') | base/task_scheduler/task_scheduler_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698