| OLD | NEW |
| 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 <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/base_export.h" | 12 #include "base/base_export.h" |
| 13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
| 16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/task_runner.h" | 17 #include "base/task_runner.h" |
| 18 #include "base/task_scheduler/task_traits.h" | 18 #include "base/task_scheduler/task_traits.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "build/build_config.h" |
| 20 | 21 |
| 21 namespace gin { | 22 namespace gin { |
| 22 class V8Platform; | 23 class V8Platform; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace tracked_objects { | 26 namespace tracked_objects { |
| 26 class Location; | 27 class Location; |
| 27 } | 28 } |
| 28 | 29 |
| 29 namespace base { | 30 namespace base { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // scheduling tasks using |traits|. Tasks run one at a time in posting order. | 66 // scheduling tasks using |traits|. Tasks run one at a time in posting order. |
| 66 virtual scoped_refptr<SequencedTaskRunner> | 67 virtual scoped_refptr<SequencedTaskRunner> |
| 67 CreateSequencedTaskRunnerWithTraits(const TaskTraits& traits) = 0; | 68 CreateSequencedTaskRunnerWithTraits(const TaskTraits& traits) = 0; |
| 68 | 69 |
| 69 // Returns a SingleThreadTaskRunner whose PostTask invocations result in | 70 // Returns a SingleThreadTaskRunner whose PostTask invocations result in |
| 70 // scheduling tasks using |traits|. Tasks run on a single thread in posting | 71 // scheduling tasks using |traits|. Tasks run on a single thread in posting |
| 71 // order. | 72 // order. |
| 72 virtual scoped_refptr<SingleThreadTaskRunner> | 73 virtual scoped_refptr<SingleThreadTaskRunner> |
| 73 CreateSingleThreadTaskRunnerWithTraits(const TaskTraits& traits) = 0; | 74 CreateSingleThreadTaskRunnerWithTraits(const TaskTraits& traits) = 0; |
| 74 | 75 |
| 76 #if defined(OS_WIN) |
| 77 // Returns a SingleThreadTaskRunner whose PostTask invocations result in |
| 78 // scheduling tasks using |traits| in a COM Single-Threaded Apartment. Tasks |
| 79 // run in the same Single-Threaded Apartment in posting order for the returned |
| 80 // SingleThreadTaskRunner. Different SingleThreadTaskRunners may be associated |
| 81 // with different Single-Threaded Apartments so care should be taken to make |
| 82 // sure COM pointers are not smuggled across apartments. |
| 83 virtual scoped_refptr<SingleThreadTaskRunner> |
| 84 CreateCOMSTATaskRunnerWithTraits(const TaskTraits& traits) = 0; |
| 85 #endif // defined(OS_WIN) |
| 86 |
| 75 // Returns a vector of all histograms available in this task scheduler. | 87 // Returns a vector of all histograms available in this task scheduler. |
| 76 virtual std::vector<const HistogramBase*> GetHistograms() const = 0; | 88 virtual std::vector<const HistogramBase*> GetHistograms() const = 0; |
| 77 | 89 |
| 78 // Synchronously shuts down the scheduler. Once this is called, only tasks | 90 // Synchronously shuts down the scheduler. Once this is called, only tasks |
| 79 // posted with the BLOCK_SHUTDOWN behavior will be run. When this returns: | 91 // posted with the BLOCK_SHUTDOWN behavior will be run. When this returns: |
| 80 // - All SKIP_ON_SHUTDOWN tasks that were already running have completed their | 92 // - All SKIP_ON_SHUTDOWN tasks that were already running have completed their |
| 81 // execution. | 93 // execution. |
| 82 // - All posted BLOCK_SHUTDOWN tasks have completed their execution. | 94 // - All posted BLOCK_SHUTDOWN tasks have completed their execution. |
| 83 // - CONTINUE_ON_SHUTDOWN tasks might still be running. | 95 // - CONTINUE_ON_SHUTDOWN tasks might still be running. |
| 84 // Note that an implementation can keep threads and other resources alive to | 96 // Note that an implementation can keep threads and other resources alive to |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // each process n/GetMaxConcurrentTasksWithTraitsDeprecated() items. | 167 // each process n/GetMaxConcurrentTasksWithTraitsDeprecated() items. |
| 156 // | 168 // |
| 157 // TODO(fdoray): Remove this method. https://crbug.com/687264 | 169 // TODO(fdoray): Remove this method. https://crbug.com/687264 |
| 158 virtual int GetMaxConcurrentTasksWithTraitsDeprecated( | 170 virtual int GetMaxConcurrentTasksWithTraitsDeprecated( |
| 159 const TaskTraits& traits) const = 0; | 171 const TaskTraits& traits) const = 0; |
| 160 }; | 172 }; |
| 161 | 173 |
| 162 } // namespace base | 174 } // namespace base |
| 163 | 175 |
| 164 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ | 176 #endif // BASE_TASK_SCHEDULER_TASK_SCHEDULER_H_ |
| OLD | NEW |