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

Unified Diff: base/task_scheduler/task_scheduler.h

Issue 2749303002: [reference - do not submit] Always create four pools in TaskSchedulerImpl. (Closed)
Patch Set: rebase Created 3 years, 9 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_params.cc ('k') | base/task_scheduler/task_scheduler.cc » ('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 4b07c88998ba922f46914f7f88055b939e1947cc..6b137d9de511ebc9f1ad917794bf5524b267b1fd 100644
--- a/base/task_scheduler/task_scheduler.h
+++ b/base/task_scheduler/task_scheduler.h
@@ -15,8 +15,10 @@
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
#include "base/task_runner.h"
+#include "base/task_scheduler/scheduler_worker_pool_params.h"
#include "base/task_scheduler/task_traits.h"
#include "base/time/time.h"
+#include "build/build_config.h"
namespace gin {
class V8Platform;
@@ -29,7 +31,24 @@ class Location;
namespace base {
class HistogramBase;
-class SchedulerWorkerPoolParams;
+
+struct BASE_EXPORT TaskSchedulerInitParams {
+ TaskSchedulerInitParams(
+ const SchedulerWorkerPoolParams& background_worker_pool_params_in,
+ const SchedulerWorkerPoolParams&
+ background_blocking_worker_pool_params_in,
+ const SchedulerWorkerPoolParams& foreground_worker_pool_params_in,
+ const SchedulerWorkerPoolParams&
+ foreground_blocking_worker_pool_params_in);
+
+ // Returns true if this object can be used to initialize a task scheduler.
+ bool IsValid() const;
+
+ const SchedulerWorkerPoolParams background_worker_pool_params;
+ const SchedulerWorkerPoolParams background_blocking_worker_pool_params;
+ const SchedulerWorkerPoolParams foreground_worker_pool_params;
+ const SchedulerWorkerPoolParams foreground_blocking_worker_pool_params;
+};
// Interface for a task scheduler and static methods to manage the instance used
// by the post_task.h API. Note: all base/task_scheduler users should go through
@@ -37,12 +56,6 @@ class SchedulerWorkerPoolParams;
// which manages the process' instance.
class BASE_EXPORT TaskScheduler {
public:
- // Returns the index of the worker pool in which a task with |traits| should
- // run. This should be coded in a future-proof way: new traits should
- // gracefully map to a default pool.
- 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.
@@ -110,21 +123,23 @@ class BASE_EXPORT TaskScheduler {
#if !defined(OS_NACL)
// Creates and sets a task scheduler using default params. |name| is used to
- // label threads and histograms. It should identify the component that calls
- // this. CHECKs on failure. For tests, prefer base::test::ScopedTaskScheduler
- // (ensures isolation).
+ // label threads and histograms. It should identify the component that creates
+ // the TaskScheduler. CHECKs on failure. For tests, prefer
+ // base::test::ScopedTaskScheduler (ensures isolation).
+ //
+ // This method is not available on NaCl because there is no way to get the
+ // number of processors on that platform.
static void CreateAndSetSimpleTaskScheduler(const std::string& name);
#endif // !defined(OS_NACL)
- // Creates and sets a task scheduler with custom worker pools. CHECKs on
- // failure. |worker_pool_params_vector| describes the worker pools to create.
- // |worker_pool_index_for_traits_callback| returns the index in |worker_pools|
- // of the worker pool in which a task with given traits should run. For tests,
- // prefer base::test::ScopedTaskScheduler (ensures isolation).
+ // Creates and sets a task scheduler using custom params. |name| is used to
+ // label threads and histograms. It should identify the component that creates
+ // the TaskScheduler. |init_params| is used to initialize the worker pools.
+ // CHECKs on failure. For tests, prefer base::test::ScopedTaskScheduler
+ // (ensures isolation).
static void CreateAndSetDefaultTaskScheduler(
- const std::vector<SchedulerWorkerPoolParams>& worker_pool_params_vector,
- const WorkerPoolIndexForTraitsCallback&
- worker_pool_index_for_traits_callback);
+ const std::string& name,
+ const TaskSchedulerInitParams& init_params);
// Registers |task_scheduler| to handle tasks posted through the post_task.h
// API for this process. For tests, prefer base::test::ScopedTaskScheduler
« no previous file with comments | « base/task_scheduler/scheduler_worker_pool_params.cc ('k') | base/task_scheduler/task_scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698