review fixes

This commit is contained in:
serxa 2024-02-21 14:14:45 +00:00
parent f92ec2cd5d
commit 1ac94813ed
3 changed files with 7 additions and 5 deletions

View File

@ -134,6 +134,7 @@ public:
std::pair<ResourceRequest *, bool> dequeueRequest() override
{
// Cycle is required to do deactivations in the case of canceled requests, when dequeueRequest returns `nullptr`
while (true)
{
if (heap_size == 0)

View File

@ -39,7 +39,7 @@ public:
void enqueueRequest(ResourceRequest * request) override
{
std::unique_lock lock(mutex);
std::lock_guard lock(mutex);
queue_cost += request->cost;
bool was_empty = requests.empty();
requests.push_back(request);
@ -49,7 +49,7 @@ public:
std::pair<ResourceRequest *, bool> dequeueRequest() override
{
std::unique_lock lock(mutex);
std::lock_guard lock(mutex);
if (requests.empty())
return {nullptr, false};
ResourceRequest * result = requests.front();
@ -64,7 +64,7 @@ public:
bool cancelRequest(ResourceRequest * request) override
{
std::unique_lock lock(mutex);
std::lock_guard lock(mutex);
// TODO(serxa): reimplement queue as intrusive list of ResourceRequest to make this O(1) instead of O(N)
for (auto i = requests.begin(), e = requests.end(); i != e; ++i)
{
@ -84,7 +84,7 @@ public:
bool isActive() override
{
std::unique_lock lock(mutex);
std::lock_guard lock(mutex);
return !requests.empty();
}
@ -117,7 +117,7 @@ public:
std::pair<UInt64, Int64> getQueueLengthAndCost()
{
std::unique_lock lock(mutex);
std::lock_guard lock(mutex);
return {requests.size(), queue_cost};
}

View File

@ -102,6 +102,7 @@ public:
std::pair<ResourceRequest *, bool> dequeueRequest() override
{
// Cycle is required to do deactivations in the case of canceled requests, when dequeueRequest returns `nullptr`
while (true)
{
if (items.empty())