Compare commits
3 commits
7ec1d61b01
...
298df9d342
Author | SHA1 | Date | |
---|---|---|---|
298df9d342 | |||
18b012c148 | |||
ba20e5c2f5 |
1 changed files with 18 additions and 9 deletions
|
@ -12,6 +12,7 @@
|
||||||
#include <concepts>
|
#include <concepts>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
#include "common/alignment.h"
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/concepts.h"
|
#include "common/concepts.h"
|
||||||
|
@ -196,7 +197,12 @@ public:
|
||||||
constexpr Member* GetFront(s32 core) const {
|
constexpr Member* GetFront(s32 core) const {
|
||||||
ASSERT(IsValidCore(core));
|
ASSERT(IsValidCore(core));
|
||||||
|
|
||||||
const s32 priority = s32((~m_available_priorities[core]).count());
|
const s32 priority = s32([](auto const& e) {
|
||||||
|
for (size_t i = 0; i < e.size(); ++i)
|
||||||
|
if (e[i])
|
||||||
|
return i;
|
||||||
|
return e.size();
|
||||||
|
}(m_available_priorities[core]));
|
||||||
if (priority <= LowestPriority) {
|
if (priority <= LowestPriority) {
|
||||||
return m_queues[priority].GetFront(core);
|
return m_queues[priority].GetFront(core);
|
||||||
} else {
|
} else {
|
||||||
|
@ -215,19 +221,22 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<size_t N>
|
||||||
|
constexpr size_t GetNextSet(std::bitset<N> const& bit, size_t n) const {
|
||||||
|
for (size_t i = n + 1; i < bit.size(); i++)
|
||||||
|
if (bit[i])
|
||||||
|
return i;
|
||||||
|
return bit.size();
|
||||||
|
}
|
||||||
|
|
||||||
constexpr Member* GetNext(s32 core, const Member* member) const {
|
constexpr Member* GetNext(s32 core, const Member* member) const {
|
||||||
ASSERT(IsValidCore(core));
|
ASSERT(IsValidCore(core));
|
||||||
|
|
||||||
Member* next = member->GetPriorityQueueEntry(core).GetNext();
|
Member* next = member->GetPriorityQueueEntry(core).GetNext();
|
||||||
if (next == nullptr) {
|
if (next == nullptr) {
|
||||||
s32 priority = member->GetPriority() + 1;
|
s32 priority = s32(GetNextSet(m_available_priorities[core], member->GetPriority()));
|
||||||
do {
|
if (priority <= LowestPriority)
|
||||||
if (m_available_priorities[core][priority]) {
|
next = m_queues[priority].GetFront(core);
|
||||||
next = m_queues[priority].GetFront(core);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++priority;
|
|
||||||
} while (priority <= LowestPriority && priority < s32(m_available_priorities[core].size()));
|
|
||||||
}
|
}
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue