apache / apache/incubator-pegasus

improve priority_queue to prevent starvation

Open
#93 0 comments 0 reactions 1 assignee Claimed by @qinzuoyan View on GitHub
type/enhancement
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.