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> |
| 9 |
8 #include "base/base_export.h" | 10 #include "base/base_export.h" |
9 #include "base/callback.h" | 11 #include "base/callback.h" |
10 #include "base/macros.h" | 12 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.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 { |
19 namespace internal { | 20 namespace internal { |
20 | 21 |
21 class TaskTracker; | 22 class TaskTracker; |
22 | 23 |
(...skipping 19 matching lines...) Expand all Loading... |
42 Callback<void(const SchedulerWorkerThread* worker_thread, | 43 Callback<void(const SchedulerWorkerThread* worker_thread, |
43 scoped_refptr<Sequence> sequence)>; | 44 scoped_refptr<Sequence> sequence)>; |
44 | 45 |
45 // Creates a SchedulerWorkerThread with priority |thread_priority| that runs | 46 // Creates a SchedulerWorkerThread with priority |thread_priority| that runs |
46 // Tasks from Sequences returned by |get_work_callback|. |main_entry_callback| | 47 // Tasks from Sequences returned by |get_work_callback|. |main_entry_callback| |
47 // is invoked when the main function of the SchedulerWorkerThread is entered. | 48 // is invoked when the main function of the SchedulerWorkerThread is entered. |
48 // |ran_task_from_sequence_callback| is invoked after the | 49 // |ran_task_from_sequence_callback| is invoked after the |
49 // SchedulerWorkerThread has tried to run a Task from a Sequence returned by | 50 // SchedulerWorkerThread has tried to run a Task from a Sequence returned by |
50 // |get_work_callback|. |task_tracker| is used to handle shutdown behavior of | 51 // |get_work_callback|. |task_tracker| is used to handle shutdown behavior of |
51 // Tasks. Returns nullptr if creating the underlying platform thread fails. | 52 // Tasks. Returns nullptr if creating the underlying platform thread fails. |
52 static scoped_ptr<SchedulerWorkerThread> CreateSchedulerWorkerThread( | 53 static std::unique_ptr<SchedulerWorkerThread> CreateSchedulerWorkerThread( |
53 ThreadPriority thread_priority, | 54 ThreadPriority thread_priority, |
54 const Closure& main_entry_callback, | 55 const Closure& main_entry_callback, |
55 const GetWorkCallback& get_work_callback, | 56 const GetWorkCallback& get_work_callback, |
56 const RanTaskFromSequenceCallback& ran_task_from_sequence_callback, | 57 const RanTaskFromSequenceCallback& ran_task_from_sequence_callback, |
57 TaskTracker* task_tracker); | 58 TaskTracker* task_tracker); |
58 | 59 |
59 // Destroying a SchedulerWorkerThread in production is not allowed; it is | 60 // Destroying a SchedulerWorkerThread in production is not allowed; it is |
60 // always leaked. In tests, it can only be destroyed after JoinForTesting() | 61 // always leaked. In tests, it can only be destroyed after JoinForTesting() |
61 // has returned. | 62 // has returned. |
62 ~SchedulerWorkerThread() override; | 63 ~SchedulerWorkerThread() override; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // True once JoinForTesting() has been called. | 101 // True once JoinForTesting() has been called. |
101 bool should_exit_for_testing_ = false; | 102 bool should_exit_for_testing_ = false; |
102 | 103 |
103 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerThread); | 104 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerThread); |
104 }; | 105 }; |
105 | 106 |
106 } // namespace internal | 107 } // namespace internal |
107 } // namespace base | 108 } // namespace base |
108 | 109 |
109 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_THREAD_H_ | 110 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_THREAD_H_ |
OLD | NEW |