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_THREAD_H_ | 5 #ifndef BASE_TASK_SCHEDULER_SCHEDULER_WORKER_THREAD_H_ |
6 #define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_THREAD_H_ | 6 #define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_THREAD_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
| 9 #include <string> |
9 | 10 |
10 #include "base/base_export.h" | 11 #include "base/base_export.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
14 #include "base/task_scheduler/scheduler_lock.h" | 15 #include "base/task_scheduler/scheduler_lock.h" |
15 #include "base/task_scheduler/sequence.h" | 16 #include "base/task_scheduler/sequence.h" |
16 #include "base/threading/platform_thread.h" | 17 #include "base/threading/platform_thread.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 static std::unique_ptr<SchedulerWorkerThread> Create( | 57 static std::unique_ptr<SchedulerWorkerThread> Create( |
57 ThreadPriority thread_priority, | 58 ThreadPriority thread_priority, |
58 std::unique_ptr<Delegate> delegate, | 59 std::unique_ptr<Delegate> delegate, |
59 TaskTracker* task_tracker); | 60 TaskTracker* task_tracker); |
60 | 61 |
61 // Destroying a SchedulerWorkerThread in production is not allowed; it is | 62 // Destroying a SchedulerWorkerThread in production is not allowed; it is |
62 // always leaked. In tests, it can only be destroyed after JoinForTesting() | 63 // always leaked. In tests, it can only be destroyed after JoinForTesting() |
63 // has returned. | 64 // has returned. |
64 ~SchedulerWorkerThread() override; | 65 ~SchedulerWorkerThread() override; |
65 | 66 |
| 67 std::string GetThreadName() const; |
| 68 |
66 // Wakes up this SchedulerWorkerThread if it wasn't already awake. After this | 69 // Wakes up this SchedulerWorkerThread if it wasn't already awake. After this |
67 // is called, this SchedulerWorkerThread will run Tasks from Sequences | 70 // is called, this SchedulerWorkerThread will run Tasks from Sequences |
68 // returned by the GetWork() method of its delegate until it returns nullptr. | 71 // returned by the GetWork() method of its delegate until it returns nullptr. |
69 void WakeUp(); | 72 void WakeUp(); |
70 | 73 |
71 SchedulerWorkerThread::Delegate* delegate() { return delegate_.get(); } | 74 SchedulerWorkerThread::Delegate* delegate() { return delegate_.get(); } |
72 | 75 |
73 // Joins this SchedulerWorkerThread. If a Task is already running, it will be | 76 // Joins this SchedulerWorkerThread. If a Task is already running, it will be |
74 // allowed to complete its execution. This can only be called once. | 77 // allowed to complete its execution. This can only be called once. |
75 void JoinForTesting(); | 78 void JoinForTesting(); |
(...skipping 23 matching lines...) Expand all Loading... |
99 // True once JoinForTesting() has been called. | 102 // True once JoinForTesting() has been called. |
100 bool should_exit_for_testing_ = false; | 103 bool should_exit_for_testing_ = false; |
101 | 104 |
102 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerThread); | 105 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerThread); |
103 }; | 106 }; |
104 | 107 |
105 } // namespace internal | 108 } // namespace internal |
106 } // namespace base | 109 } // namespace base |
107 | 110 |
108 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_THREAD_H_ | 111 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_THREAD_H_ |
OLD | NEW |