summaryrefslogtreecommitdiffstats
path: root/src/common/multi_level_queue.h
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-03-20 03:20:15 +0100
committerFernandoS27 <fsahmkow27@gmail.com>2019-03-27 19:49:43 +0100
commitdb42bcb306323d6221e7f893d39558c3db579bf3 (patch)
treeef23218b123f80a0c2a773908a6fa2685cd34898 /src/common/multi_level_queue.h
parentFixes to multilevelqueue's iterator. (diff)
downloadyuzu-db42bcb306323d6221e7f893d39558c3db579bf3.tar
yuzu-db42bcb306323d6221e7f893d39558c3db579bf3.tar.gz
yuzu-db42bcb306323d6221e7f893d39558c3db579bf3.tar.bz2
yuzu-db42bcb306323d6221e7f893d39558c3db579bf3.tar.lz
yuzu-db42bcb306323d6221e7f893d39558c3db579bf3.tar.xz
yuzu-db42bcb306323d6221e7f893d39558c3db579bf3.tar.zst
yuzu-db42bcb306323d6221e7f893d39558c3db579bf3.zip
Diffstat (limited to '')
-rw-r--r--src/common/multi_level_queue.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/common/multi_level_queue.h b/src/common/multi_level_queue.h
index 68b35ffaa..2b61b91e0 100644
--- a/src/common/multi_level_queue.h
+++ b/src/common/multi_level_queue.h
@@ -7,12 +7,21 @@
#include <array>
#include <iterator>
#include <list>
+#include <utility>
#include "common/bit_util.h"
#include "common/common_types.h"
namespace Common {
+/**
+ * A MultiLevelQueue is a type of priority queue which has the following characteristics:
+ * - iteratable through each of its elements.
+ * - back can be obtained.
+ * - O(1) add, lookup (both front and back)
+ * - discrete priorities and a max of 64 priorities (limited domain)
+ * This type of priority queue is normaly used for managing threads within an scheduler
+ */
template <typename T, std::size_t Depth>
class MultiLevelQueue {
public:
@@ -37,9 +46,7 @@ public:
friend bool operator==(const iterator_impl& lhs, const iterator_impl& rhs) {
if (lhs.IsEnd() && rhs.IsEnd())
return true;
- if (lhs.current_priority == rhs.current_priority)
- return lhs.it == rhs.it;
- return false;
+ return std::tie(lhs.current_priority, lhs.it) == std::tie(rhs.current_priority, rhs.it);
}
friend bool operator!=(const iterator_impl& lhs, const iterator_impl& rhs) {
@@ -301,7 +308,6 @@ private:
using const_list_iterator = typename std::list<T>::const_iterator;
static void ListShiftForward(std::list<T>& list, const std::size_t shift = 1) {
- // NOTE: May want to consider making this an assertion or something
if (shift >= list.size()) {
return;
}