OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_MESSAGE_LOOP_INCOMING_TASK_QUEUE_H_ | 5 #ifndef BASE_MESSAGE_LOOP_INCOMING_TASK_QUEUE_H_ |
6 #define BASE_MESSAGE_LOOP_INCOMING_TASK_QUEUE_H_ | 6 #define BASE_MESSAGE_LOOP_INCOMING_TASK_QUEUE_H_ |
7 | 7 |
8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/pending_task.h" | 10 #include "base/pending_task.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 bool IsIdleForTesting(); | 46 bool IsIdleForTesting(); |
47 | 47 |
48 // Loads tasks from the |incoming_queue_| into |*work_queue|. Must be called | 48 // Loads tasks from the |incoming_queue_| into |*work_queue|. Must be called |
49 // from the thread that is running the loop. Returns the number of tasks that | 49 // from the thread that is running the loop. Returns the number of tasks that |
50 // require high resolution timers. | 50 // require high resolution timers. |
51 int ReloadWorkQueue(TaskQueue* work_queue); | 51 int ReloadWorkQueue(TaskQueue* work_queue); |
52 | 52 |
53 // Disconnects |this| from the parent message loop. | 53 // Disconnects |this| from the parent message loop. |
54 void WillDestroyCurrentMessageLoop(); | 54 void WillDestroyCurrentMessageLoop(); |
55 | 55 |
56 // This should be called when it's ready for scheduling work. | |
57 void StartScheduling(); | |
58 | |
59 // Returns true if this has no queued tasks. | |
60 bool empty(); | |
danakj
2015/04/24 20:54:39
IsEmpty
Nico
2015/04/24 21:31:15
style nit: lower_names() only for trivial methods.
kinuko
2015/04/27 16:36:04
Done. (Removed this method)
| |
61 | |
56 private: | 62 private: |
57 friend class RefCountedThreadSafe<IncomingTaskQueue>; | 63 friend class RefCountedThreadSafe<IncomingTaskQueue>; |
58 virtual ~IncomingTaskQueue(); | 64 virtual ~IncomingTaskQueue(); |
59 | 65 |
60 // Calculates the time at which a PendingTask should run. | 66 // Calculates the time at which a PendingTask should run. |
61 TimeTicks CalculateDelayedRuntime(TimeDelta delay); | 67 TimeTicks CalculateDelayedRuntime(TimeDelta delay); |
62 | 68 |
63 // Adds a task to |incoming_queue_|. The caller retains ownership of | 69 // Adds a task to |incoming_queue_|. The caller retains ownership of |
64 // |pending_task|, but this function will reset the value of | 70 // |pending_task|, but this function will reset the value of |
65 // |pending_task->task|. This is needed to ensure that the posting call stack | 71 // |pending_task->task|. This is needed to ensure that the posting call stack |
(...skipping 19 matching lines...) Expand all Loading... | |
85 int next_sequence_num_; | 91 int next_sequence_num_; |
86 | 92 |
87 // True if our message loop has already been scheduled and does not need to be | 93 // True if our message loop has already been scheduled and does not need to be |
88 // scheduled again until an empty reload occurs. | 94 // scheduled again until an empty reload occurs. |
89 bool message_loop_scheduled_; | 95 bool message_loop_scheduled_; |
90 | 96 |
91 // True if we always need to call ScheduleWork when receiving a new task, even | 97 // True if we always need to call ScheduleWork when receiving a new task, even |
92 // if the incoming queue was not empty. | 98 // if the incoming queue was not empty. |
93 const bool always_schedule_work_; | 99 const bool always_schedule_work_; |
94 | 100 |
101 // False until StartScheduling() is called. | |
102 bool is_ready_for_scheduling_ = false; | |
danakj
2015/04/24 20:54:39
please initialize it in the constructor where othe
Nico
2015/04/24 21:31:15
nit: let's not mix member initialization style in
kinuko
2015/04/27 16:36:04
Done.
| |
103 | |
95 DISALLOW_COPY_AND_ASSIGN(IncomingTaskQueue); | 104 DISALLOW_COPY_AND_ASSIGN(IncomingTaskQueue); |
96 }; | 105 }; |
97 | 106 |
98 } // namespace internal | 107 } // namespace internal |
99 } // namespace base | 108 } // namespace base |
100 | 109 |
101 #endif // BASE_MESSAGE_LOOP_INCOMING_TASK_QUEUE_H_ | 110 #endif // BASE_MESSAGE_LOOP_INCOMING_TASK_QUEUE_H_ |
OLD | NEW |