apache / apache/incubator-pegasus
improve priority_queue to prevent starvation
- Dominant language
- C++
- Stars
- 2.1k
- Forks
- 328
- PR merge metrics
- No merged PRs in 30d
Description
now the priority queue's dequeue() is:
```cpp
T dequeue_impl(/*out*/ long &ct, bool pop = true)
{
if (_count == 0) {
ct = 0;
return nullptr;
}
ct = --_count;
int index = priority_count - 1;
for (; index >= 0; index--) {
if (_items[index].size() > 0) {
break;
}
}
assert(index >= 0); // "must find something");
auto c = _items[index].front();
_items[index].pop();
return c;
}
```
if the HIGH priority queue is always not empty, the task in COMMON/LOW queue may be starved.
we can refer to the implementation of nfs_client_impl.
Contributor guide
Assessment
This issue has not been assessed yet.