query capacity before popping (#16828)

* query capacity before popping

Signed-off-by: fishbell <bell.song@intel.com>

* refine

Signed-off-by: fishbell <bell.song@intel.com>

---------

Signed-off-by: fishbell <bell.song@intel.com>
This commit is contained in:
yanlan song
2023-04-11 11:25:29 +04:00
committed by GitHub
parent 615177ae09
commit 527c2dad2a
@@ -62,7 +62,7 @@ public:
return false;
}
bool try_pop(T& value) {
return _pqueue.try_pop(value);
return _capacity ? _pqueue.try_pop(value) : false;
}
void set_capacity(std::size_t newCapacity) {
_capacity = newCapacity;