Skip to content

Commit

Permalink
fix: reserve extra size for high priority request in priority queue
Browse files Browse the repository at this point in the history
  • Loading branch information
obdev authored and ob-robot committed Aug 11, 2023
1 parent 019cb49 commit 14e357b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion deps/oblib/src/lib/queue/ob_priority_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,15 @@ class ObPriorityQueue2
int push(ObLink* data, int priority)
{
int ret = OB_SUCCESS;
if (ATOMIC_FAA(&size_, 1) > limit_) {
int64_t extra;
if (priority < HIGH_PRIOS) {
extra = 2048;
} else if (priority < NORMAL_PRIOS + HIGH_PRIOS) {
extra = 1024;
} else {
extra = 0;
}
if (ATOMIC_FAA(&size_, 1) > limit_ + extra) {
ret = OB_SIZE_OVERFLOW;
} else if (OB_UNLIKELY(NULL == data) || OB_UNLIKELY(priority < 0) || OB_UNLIKELY(priority >= PRIO_CNT)) {
ret = OB_INVALID_ARGUMENT;
Expand Down

0 comments on commit 14e357b

Please sign in to comment.