| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ |
| 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // is scheduled with the TimeDomain. When the delay has elapsed, the TimeDomain | 50 // is scheduled with the TimeDomain. When the delay has elapsed, the TimeDomain |
| 51 // calls UpdateDelayedWorkQueue and ready delayed tasks are moved into the | 51 // calls UpdateDelayedWorkQueue and ready delayed tasks are moved into the |
| 52 // delayed_work_queue. Note the EnqueueOrder (used for ordering) for a delayed | 52 // delayed_work_queue. Note the EnqueueOrder (used for ordering) for a delayed |
| 53 // task is not set until it's moved into the delayed_work_queue. | 53 // task is not set until it's moved into the delayed_work_queue. |
| 54 // | 54 // |
| 55 // TaskQueueImpl uses the WorkQueueSets and the TaskQueueSelector to implement | 55 // TaskQueueImpl uses the WorkQueueSets and the TaskQueueSelector to implement |
| 56 // prioritization. Task selection is done by the TaskQueueSelector and when a | 56 // prioritization. Task selection is done by the TaskQueueSelector and when a |
| 57 // queue is selected, it round-robins between the immediate_work_queue and | 57 // queue is selected, it round-robins between the immediate_work_queue and |
| 58 // delayed_work_queue. The reason for this is we want to make sure delayed | 58 // delayed_work_queue. The reason for this is we want to make sure delayed |
| 59 // tasks (normally the most common type) don't starve out immediate work. | 59 // tasks (normally the most common type) don't starve out immediate work. |
| 60 class BLINK_PLATFORM_EXPORT TaskQueueImpl final : public TaskQueue { | 60 class PLATFORM_EXPORT TaskQueueImpl final : public TaskQueue { |
| 61 public: | 61 public: |
| 62 TaskQueueImpl(TaskQueueManager* task_queue_manager, | 62 TaskQueueImpl(TaskQueueManager* task_queue_manager, |
| 63 TimeDomain* time_domain, | 63 TimeDomain* time_domain, |
| 64 const Spec& spec, | 64 const Spec& spec, |
| 65 const char* disabled_by_default_tracing_category, | 65 const char* disabled_by_default_tracing_category, |
| 66 const char* disabled_by_default_verbose_tracing_category); | 66 const char* disabled_by_default_verbose_tracing_category); |
| 67 | 67 |
| 68 // Represents a time at which a task wants to run. Tasks scheduled for the | 68 // Represents a time at which a task wants to run. Tasks scheduled for the |
| 69 // same point in time will be ordered by their sequence numbers. | 69 // same point in time will be ordered by their sequence numbers. |
| 70 struct DelayedWakeUp { | 70 struct DelayedWakeUp { |
| 71 base::TimeTicks time; | 71 base::TimeTicks time; |
| 72 int sequence_num; | 72 int sequence_num; |
| 73 | 73 |
| 74 bool operator<=(const DelayedWakeUp& other) const { | 74 bool operator<=(const DelayedWakeUp& other) const { |
| 75 if (time == other.time) { | 75 if (time == other.time) { |
| 76 DCHECK_NE(sequence_num, other.sequence_num); | 76 DCHECK_NE(sequence_num, other.sequence_num); |
| 77 return (sequence_num - other.sequence_num) < 0; | 77 return (sequence_num - other.sequence_num) < 0; |
| 78 } | 78 } |
| 79 return time < other.time; | 79 return time < other.time; |
| 80 } | 80 } |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 class BLINK_PLATFORM_EXPORT Task : public base::PendingTask { | 83 class PLATFORM_EXPORT Task : public base::PendingTask { |
| 84 public: | 84 public: |
| 85 Task(); | 85 Task(); |
| 86 Task(const tracked_objects::Location& posted_from, | 86 Task(const tracked_objects::Location& posted_from, |
| 87 base::OnceClosure task, | 87 base::OnceClosure task, |
| 88 base::TimeTicks desired_run_time, | 88 base::TimeTicks desired_run_time, |
| 89 EnqueueOrder sequence_number, | 89 EnqueueOrder sequence_number, |
| 90 bool nestable); | 90 bool nestable); |
| 91 | 91 |
| 92 Task(const tracked_objects::Location& posted_from, | 92 Task(const tracked_objects::Location& posted_from, |
| 93 base::OnceClosure task, | 93 base::OnceClosure task, |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 const bool should_report_when_execution_blocked_; | 387 const bool should_report_when_execution_blocked_; |
| 388 | 388 |
| 389 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); | 389 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); |
| 390 }; | 390 }; |
| 391 | 391 |
| 392 } // namespace internal | 392 } // namespace internal |
| 393 } // namespace scheduler | 393 } // namespace scheduler |
| 394 } // namespace blink | 394 } // namespace blink |
| 395 | 395 |
| 396 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ | 396 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ |
| OLD | NEW |