Index: base/task_scheduler/task_scheduler.h |
diff --git a/base/task_scheduler/task_scheduler.h b/base/task_scheduler/task_scheduler.h |
index e36f7de53910db734ccf14bb755943418c081bfc..199a58c5a07150cc7ecb1ccfff84694429f200c4 100644 |
--- a/base/task_scheduler/task_scheduler.h |
+++ b/base/task_scheduler/task_scheduler.h |
@@ -61,6 +61,19 @@ class BASE_EXPORT TaskScheduler { |
const SchedulerWorkerPoolParams foreground_blocking_worker_pool_params; |
}; |
+ enum class SingleThreadTaskRunnerThreadMode { |
fdoray
2017/05/10 12:32:23
Declare this in a separate file, so that post_task
gab
2017/05/10 15:20:47
Agreed, feels like this belongs in task_traits.h o
robliao
2017/05/11 05:30:12
Went with a new file. This isn't really part of Ta
|
+ // Allow the SingleThreadTaskRunner's thread to be shared with others, |
+ // allowing for efficient use of thread resources when this |
+ // SingleThreadTaskRunner is idle. This is the default mode and is |
+ // recommended for most code. |
+ SHARED, |
+ // Dedicate a single thread for this SingleThreadTaskRunner. No other tasks |
+ // from any other source will be scheduled on the thread backing |
+ // the SingleThreadTaskRunner. Use sparingly as this reserves an entire |
+ // thread for this SingleThreadTaskRunner. |
+ DEDICATED, |
+ }; |
+ |
// Destroying a TaskScheduler is not allowed in production; it is always |
// leaked. In tests, it should only be destroyed after JoinForTesting() has |
// returned. |
@@ -92,7 +105,10 @@ class BASE_EXPORT TaskScheduler { |
// scheduling tasks using |traits|. Tasks run on a single thread in posting |
// order. |
virtual scoped_refptr<SingleThreadTaskRunner> |
- CreateSingleThreadTaskRunnerWithTraits(const TaskTraits& traits) = 0; |
+ CreateSingleThreadTaskRunnerWithTraits( |
+ const TaskTraits& traits, |
+ SingleThreadTaskRunnerThreadMode thread_mode = |
+ SingleThreadTaskRunnerThreadMode::SHARED) = 0; |
#if defined(OS_WIN) |
// Returns a SingleThreadTaskRunner whose PostTask invocations result in |
@@ -104,7 +120,10 @@ class BASE_EXPORT TaskScheduler { |
// apartments as necessary. In either case, care should be taken to make sure |
// COM pointers are not smuggled across apartments. |
virtual scoped_refptr<SingleThreadTaskRunner> |
- CreateCOMSTATaskRunnerWithTraits(const TaskTraits& traits) = 0; |
+ CreateCOMSTATaskRunnerWithTraits( |
+ const TaskTraits& traits, |
+ SingleThreadTaskRunnerThreadMode thread_mode = |
+ SingleThreadTaskRunnerThreadMode::SHARED) = 0; |
#endif // defined(OS_WIN) |
// Returns a vector of all histograms available in this task scheduler. |