Skip to content

Commit

Permalink
condition_results.notify_all
Browse files Browse the repository at this point in the history
  • Loading branch information
ngxson committed Feb 25, 2024
1 parent 91e7e0f commit 3b2dea1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions examples/server/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,16 +408,18 @@ struct llama_server_response {
condition_results.wait(lock, [&]{
return !queue_results.empty();
});
LOG_VERBOSE("condition_results unblock", {
{"data", queue_results[0].result_json},
});
LOG_VERBOSE("condition_results unblock", {});

for (int i = 0; i < (int) queue_results.size(); i++)
{
if (queue_results[i].id == task_id)
{
assert(queue_results[i].multitask_id == -1);
task_result res = queue_results[i];
LOG_VERBOSE("got task result", {
{"task_id", res.id},
{"data", res.result_json},
});
queue_results.erase(queue_results.begin() + i);
return res;
}
Expand Down Expand Up @@ -450,7 +452,7 @@ struct llama_server_response {
{
LOG_VERBOSE("queue_results.push_back", {});
queue_results.push_back(result);
condition_results.notify_one();
condition_results.notify_all();
return;
}
}
Expand Down

0 comments on commit 3b2dea1

Please sign in to comment.