Index: base/task_scheduler/scheduler_worker.h |
diff --git a/base/task_scheduler/scheduler_worker_thread.h b/base/task_scheduler/scheduler_worker.h |
similarity index 40% |
rename from base/task_scheduler/scheduler_worker_thread.h |
rename to base/task_scheduler/scheduler_worker.h |
index b6f0860da0ee83cc5f3d3c30ac4f908384185585..fdaf4d32c80cbae2429cf7e3b24c9db775c9bec9 100644 |
--- a/base/task_scheduler/scheduler_worker_thread.h |
+++ b/base/task_scheduler/scheduler_worker.h |
@@ -2,8 +2,8 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef BASE_TASK_SCHEDULER_SCHEDULER_WORKER_THREAD_H_ |
-#define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_THREAD_H_ |
+#ifndef BASE_TASK_SCHEDULER_SCHEDULER_WORKER_H_ |
+#define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_H_ |
#include <memory> |
@@ -23,77 +23,77 @@ class TaskTracker; |
// A thread that runs Tasks from Sequences returned by a delegate. |
// |
-// A SchedulerWorkerThread starts out sleeping. It is woken up by a call to |
-// WakeUp(). After a wake-up, a SchedulerWorkerThread runs Tasks from Sequences |
-// returned by the GetWork() method of its delegate as long as it doesn't return |
-// nullptr. It also periodically checks with its TaskTracker whether shutdown |
-// has completed and exits when it has. |
+// A SchedulerWorker starts out sleeping. It is woken up by a call to WakeUp(). |
+// After a wake-up, a SchedulerWorker runs Tasks from Sequences returned by the |
+// GetWork() method of its delegate as long as it doesn't return nullptr. It |
+// also periodically checks with its TaskTracker whether shutdown has completed |
+// and exits when it has. |
// |
// This class is thread-safe. |
-class BASE_EXPORT SchedulerWorkerThread : public PlatformThread::Delegate { |
+class BASE_EXPORT SchedulerWorker : public PlatformThread::Delegate { |
public: |
- // Delegate interface for SchedulerWorkerThread. The methods are always called |
- // from the thread managed by the SchedulerWorkerThread instance. |
+ // Delegate interface for SchedulerWorker. The methods are always called from |
+ // a thread managed by the SchedulerWorker instance. |
class Delegate { |
public: |
virtual ~Delegate() = default; |
- // Called by |worker_thread| when it enters its main function. |
- virtual void OnMainEntry(SchedulerWorkerThread* worker_thread) = 0; |
+ // Called by a thread managed by |worker| when it enters its main function. |
+ virtual void OnMainEntry(SchedulerWorker* worker) = 0; |
- // Called by |worker_thread| to get a Sequence from which to run a Task. |
- virtual scoped_refptr<Sequence> GetWork( |
- SchedulerWorkerThread* worker_thread) = 0; |
+ // Called by a thread managed by |worker| to get a Sequence from which to |
+ // run a Task. |
+ virtual scoped_refptr<Sequence> GetWork(SchedulerWorker* worker) = 0; |
- // Called when |sequence| isn't empty after the SchedulerWorkerThread pops a |
- // Task from it. |sequence| is the last Sequence returned by GetWork(). |
+ // Called when |sequence| isn't empty after the SchedulerWorker pops a Task |
+ // from it. |sequence| is the last Sequence returned by GetWork(). |
virtual void ReEnqueueSequence(scoped_refptr<Sequence> sequence) = 0; |
- // Called by |worker_thread| to determine how long to sleep before the next |
- // call to GetWork(). GetWork() may be called before this timeout expires |
- // if the thread's WakeUp() method is called. |
+ // Called by a thread to determine how long to sleep before the next call to |
+ // GetWork(). GetWork() may be called before this timeout expires if the |
+ // worker's WakeUp() method is called. |
virtual TimeDelta GetSleepTimeout() = 0; |
}; |
- // Creates a SchedulerWorkerThread with priority |thread_priority| that runs |
- // Tasks from Sequences returned by |delegate|. |task_tracker| is used to |
- // handle shutdown behavior of Tasks. Returns nullptr if creating the |
- // underlying platform thread fails. |
- static std::unique_ptr<SchedulerWorkerThread> Create( |
+ // Creates a SchedulerWorker with priority |thread_priority| that runs Tasks |
+ // from Sequences returned by |delegate|. |task_tracker| is used to handle |
+ // shutdown behavior of Tasks. Returns nullptr if creating the underlying |
+ // platform thread fails. |
+ static std::unique_ptr<SchedulerWorker> Create( |
ThreadPriority thread_priority, |
std::unique_ptr<Delegate> delegate, |
TaskTracker* task_tracker); |
- // Destroying a SchedulerWorkerThread in production is not allowed; it is |
- // always leaked. In tests, it can only be destroyed after JoinForTesting() |
- // has returned. |
- ~SchedulerWorkerThread() override; |
+ // Destroying a SchedulerWorker in production is not allowed; it is always |
+ // leaked. In tests, it can only be destroyed after JoinForTesting() has |
+ // returned. |
+ ~SchedulerWorker() override; |
- // Wakes up this SchedulerWorkerThread if it wasn't already awake. After this |
- // is called, this SchedulerWorkerThread will run Tasks from Sequences |
+ // Wakes up this SchedulerWorker if it wasn't already awake. After this |
+ // is called, this SchedulerWorker will run Tasks from Sequences |
// returned by the GetWork() method of its delegate until it returns nullptr. |
void WakeUp(); |
- SchedulerWorkerThread::Delegate* delegate() { return delegate_.get(); } |
+ SchedulerWorker::Delegate* delegate() { return delegate_.get(); } |
- // Joins this SchedulerWorkerThread. If a Task is already running, it will be |
+ // Joins this SchedulerWorker. If a Task is already running, it will be |
// allowed to complete its execution. This can only be called once. |
void JoinForTesting(); |
private: |
- SchedulerWorkerThread(ThreadPriority thread_priority, |
- std::unique_ptr<Delegate> delegate, |
- TaskTracker* task_tracker); |
+ SchedulerWorker(ThreadPriority thread_priority, |
+ std::unique_ptr<Delegate> delegate, |
+ TaskTracker* task_tracker); |
// PlatformThread::Delegate: |
void ThreadMain() override; |
bool ShouldExitForTesting() const; |
- // Platform thread managed by this SchedulerWorkerThread. |
+ // Platform thread managed by this SchedulerWorker. |
PlatformThreadHandle thread_handle_; |
- // Event signaled to wake up this SchedulerWorkerThread. |
+ // Event signaled to wake up this SchedulerWorker. |
WaitableEvent wake_up_event_; |
const std::unique_ptr<Delegate> delegate_; |
@@ -105,10 +105,10 @@ class BASE_EXPORT SchedulerWorkerThread : public PlatformThread::Delegate { |
// True once JoinForTesting() has been called. |
bool should_exit_for_testing_ = false; |
- DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerThread); |
+ DISALLOW_COPY_AND_ASSIGN(SchedulerWorker); |
}; |
} // namespace internal |
} // namespace base |
-#endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_THREAD_H_ |
+#endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_H_ |