diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-07-31 15:50:41 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-08-30 12:35:23 +0000 |
commit | 7b2ffa587235a47d4094787d72f38102089f402a (patch) | |
tree | 30e82af9cbab08a7fa028bb18f4f2987a3f74dfa /chromium/base/task/thread_pool/priority_queue.h | |
parent | d94af01c90575348c4e81a418257f254b6f8d225 (diff) |
BASELINE: Update Chromium to 76.0.3809.94
Change-Id: I321c3f5f929c105aec0f98c5091ef6108822e647
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/base/task/thread_pool/priority_queue.h')
-rw-r--r-- | chromium/base/task/thread_pool/priority_queue.h | 63 |
1 files changed, 30 insertions, 33 deletions
diff --git a/chromium/base/task/thread_pool/priority_queue.h b/chromium/base/task/thread_pool/priority_queue.h index 0020045d73d..395f49bdc2d 100644 --- a/chromium/base/task/thread_pool/priority_queue.h +++ b/chromium/base/task/thread_pool/priority_queue.h @@ -10,15 +10,15 @@ #include "base/base_export.h" #include "base/macros.h" #include "base/memory/ref_counted.h" +#include "base/task/common/checked_lock.h" #include "base/task/common/intrusive_heap.h" -#include "base/task/thread_pool/scheduler_lock.h" -#include "base/task/thread_pool/sequence.h" #include "base/task/thread_pool/sequence_sort_key.h" +#include "base/task/thread_pool/task_source.h" namespace base { namespace internal { -// A PriorityQueue holds Sequences of Tasks. This class is not thread-safe +// A PriorityQueue holds TaskSources of Tasks. This class is not thread-safe // (requires external synchronization). class BASE_EXPORT PriorityQueue { public: @@ -27,12 +27,8 @@ class BASE_EXPORT PriorityQueue { PriorityQueue& operator=(PriorityQueue&& other); - // Inserts |sequence| in the PriorityQueue with |sequence_sort_key|. Note: - // |sequence_sort_key| is required as a parameter instead of being extracted - // from |sequence| in Push() to avoid this Transaction having a lock - // interdependency with |sequence|. - void Push(scoped_refptr<Sequence> sequence, - const SequenceSortKey& sequence_sort_key); + // Inserts |task_source| in the PriorityQueue with |sequence_sort_key|. + void Push(RegisteredTaskSourceAndTransaction task_source_and_transaction); // Returns a reference to the SequenceSortKey representing the priority of // the highest pending task in this PriorityQueue. The reference becomes @@ -40,53 +36,54 @@ class BASE_EXPORT PriorityQueue { // Cannot be called on an empty PriorityQueue. const SequenceSortKey& PeekSortKey() const; - // Removes and returns the highest priority Sequence in this PriorityQueue. + // Removes and returns the highest priority TaskSource in this PriorityQueue. // Cannot be called on an empty PriorityQueue. - scoped_refptr<Sequence> PopSequence(); + RegisteredTaskSource PopTaskSource(); - // Removes |sequence| from the PriorityQueue. Returns true if successful, or - // false if |sequence| is not currently in the PriorityQueue or the - // PriorityQueue is empty. - bool RemoveSequence(scoped_refptr<Sequence> sequence); + // Removes |task_source| from the PriorityQueue. Returns a + // RegisteredTaskSource which evaluates to true if successful, or false if + // |task_source| is not currently in the PriorityQueue or the PriorityQueue is + // empty. + RegisteredTaskSource RemoveTaskSource(scoped_refptr<TaskSource> task_source); - // Updates the sort key of the Sequence in |sequence_and_transaction| to - // match its current traits. No-ops if the Sequence is not in the + // Updates the sort key of the TaskSource in |task_source_and_transaction| to + // match its current traits. No-ops if the TaskSource is not in the // PriorityQueue or the PriorityQueue is empty. - void UpdateSortKey(SequenceAndTransaction sequence_and_transaction); + void UpdateSortKey(TaskSourceAndTransaction task_source_and_transaction); // Returns true if the PriorityQueue is empty. bool IsEmpty() const; - // Returns the number of Sequences in the PriorityQueue. + // Returns the number of TaskSources in the PriorityQueue. size_t Size() const; - // Returns the number of Sequences with |priority|. - size_t GetNumSequencesWithPriority(TaskPriority priority) const { - return num_sequences_per_priority_[static_cast<int>(priority)]; + // Returns the number of TaskSources with |priority|. + size_t GetNumTaskSourcesWithPriority(TaskPriority priority) const { + return num_task_sources_per_priority_[static_cast<int>(priority)]; } - // Set the PriorityQueue to empty all its Sequences of Tasks when it is + // Set the PriorityQueue to empty all its TaskSources of Tasks when it is // destroyed; needed to prevent memory leaks caused by a reference cycle - // (Sequence -> Task -> TaskRunner -> Sequence...) during test teardown. - void EnableFlushSequencesOnDestroyForTesting(); + // (TaskSource -> Task -> TaskRunner -> TaskSource...) during test teardown. + void EnableFlushTaskSourcesOnDestroyForTesting(); private: - // A class combining a Sequence and the SequenceSortKey that determines its + // A class combining a TaskSource and the SequenceSortKey that determines its // position in a PriorityQueue. - class SequenceAndSortKey; + class TaskSourceAndSortKey; - using ContainerType = IntrusiveHeap<SequenceAndSortKey>; + using ContainerType = IntrusiveHeap<TaskSourceAndSortKey>; - void DecrementNumSequencesForPriority(TaskPriority priority); - void IncrementNumSequencesForPriority(TaskPriority priority); + void DecrementNumTaskSourcesForPriority(TaskPriority priority); + void IncrementNumTaskSourcesForPriority(TaskPriority priority); ContainerType container_; std::array<size_t, static_cast<int>(TaskPriority::HIGHEST) + 1> - num_sequences_per_priority_ = {}; + num_task_sources_per_priority_ = {}; - // Should only be enabled by EnableFlushSequencesOnDestroyForTesting(). - bool is_flush_sequences_on_destroy_enabled_ = false; + // Should only be enabled by EnableFlushTaskSourcesOnDestroyForTesting(). + bool is_flush_task_sources_on_destroy_enabled_ = false; DISALLOW_COPY_AND_ASSIGN(PriorityQueue); }; |