| 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_SCHEDULER_WORKER_POOL_IMPL_H_ | 5 #ifndef BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ | 
| 6 #define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ | 6 #define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ | 
| 7 | 7 | 
| 8 #include <stddef.h> | 8 #include <stddef.h> | 
| 9 | 9 | 
| 10 #include <memory> | 10 #include <memory> | 
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 107                               io_restriction, | 107                               io_restriction, | 
| 108                           const TimeDelta& suggested_reclaim_time, | 108                           const TimeDelta& suggested_reclaim_time, | 
| 109                           TaskTracker* task_tracker, | 109                           TaskTracker* task_tracker, | 
| 110                           DelayedTaskManager* delayed_task_manager); | 110                           DelayedTaskManager* delayed_task_manager); | 
| 111 | 111 | 
| 112   bool Initialize( | 112   bool Initialize( | 
| 113       ThreadPriority priority_hint, | 113       ThreadPriority priority_hint, | 
| 114       size_t max_threads, | 114       size_t max_threads, | 
| 115       const ReEnqueueSequenceCallback& re_enqueue_sequence_callback); | 115       const ReEnqueueSequenceCallback& re_enqueue_sequence_callback); | 
| 116 | 116 | 
|  | 117   // Wakes up |worker|. | 
|  | 118   void WakeUpWorker(SchedulerWorker* worker); | 
|  | 119 | 
| 117   // Wakes up the last worker from this worker pool to go idle, if any. | 120   // Wakes up the last worker from this worker pool to go idle, if any. | 
| 118   void WakeUpOneWorker(); | 121   void WakeUpOneWorker(); | 
| 119 | 122 | 
| 120   // Adds |worker| to |idle_workers_stack_|. | 123   // Adds |worker| to |idle_workers_stack_|. | 
| 121   void AddToIdleWorkersStack(SchedulerWorker* worker); | 124   void AddToIdleWorkersStack(SchedulerWorker* worker); | 
| 122 | 125 | 
| 123   // Peeks from |idle_workers_stack_|. | 126   // Peeks from |idle_workers_stack_|. | 
| 124   const SchedulerWorker* PeekAtIdleWorkersStack() const; | 127   const SchedulerWorker* PeekAtIdleWorkersStack() const; | 
| 125 | 128 | 
| 126   // Removes |worker| from |idle_workers_stack_|. | 129   // Removes |worker| from |idle_workers_stack_|. | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 152   // Suggested reclaim time for workers. | 155   // Suggested reclaim time for workers. | 
| 153   const TimeDelta suggested_reclaim_time_; | 156   const TimeDelta suggested_reclaim_time_; | 
| 154 | 157 | 
| 155   // Synchronizes access to |idle_workers_stack_| and | 158   // Synchronizes access to |idle_workers_stack_| and | 
| 156   // |idle_workers_stack_cv_for_testing_|. Has |shared_priority_queue_|'s | 159   // |idle_workers_stack_cv_for_testing_|. Has |shared_priority_queue_|'s | 
| 157   // lock as its predecessor so that a worker can be pushed to | 160   // lock as its predecessor so that a worker can be pushed to | 
| 158   // |idle_workers_stack_| within the scope of a Transaction (more | 161   // |idle_workers_stack_| within the scope of a Transaction (more | 
| 159   // details in GetWork()). | 162   // details in GetWork()). | 
| 160   mutable SchedulerLock idle_workers_stack_lock_; | 163   mutable SchedulerLock idle_workers_stack_lock_; | 
| 161 | 164 | 
| 162   // Stack of idle workers. | 165   // Stack of idle workers. Initially, all workers are on this stack. A worker | 
|  | 166   // is removed from the stack before its WakeUp() function is called and when | 
|  | 167   // it receives work from GetWork() (a worker calls GetWork() when its sleep | 
|  | 168   // timeout expires, even if its WakeUp() method hasn't been called). A worker | 
|  | 169   // is pushed on this stack when it receives nullptr from GetWork(). | 
| 163   SchedulerWorkerStack idle_workers_stack_; | 170   SchedulerWorkerStack idle_workers_stack_; | 
| 164 | 171 | 
| 165   // Signaled when all workers become idle. | 172   // Signaled when all workers become idle. | 
| 166   std::unique_ptr<ConditionVariable> idle_workers_stack_cv_for_testing_; | 173   std::unique_ptr<ConditionVariable> idle_workers_stack_cv_for_testing_; | 
| 167 | 174 | 
| 168   // Signaled once JoinForTesting() has returned. | 175   // Signaled once JoinForTesting() has returned. | 
| 169   WaitableEvent join_for_testing_returned_; | 176   WaitableEvent join_for_testing_returned_; | 
| 170 | 177 | 
| 171   // Indicates to the delegates that workers are not permitted to detach their | 178   // Indicates to the delegates that workers are not permitted to detach their | 
| 172   // threads. | 179   // threads. | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 196   TaskTracker* const task_tracker_; | 203   TaskTracker* const task_tracker_; | 
| 197   DelayedTaskManager* const delayed_task_manager_; | 204   DelayedTaskManager* const delayed_task_manager_; | 
| 198 | 205 | 
| 199   DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolImpl); | 206   DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolImpl); | 
| 200 }; | 207 }; | 
| 201 | 208 | 
| 202 }  // namespace internal | 209 }  // namespace internal | 
| 203 }  // namespace base | 210 }  // namespace base | 
| 204 | 211 | 
| 205 #endif  // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ | 212 #endif  // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ | 
| OLD | NEW | 
|---|