MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / recv_with_timeout

Method recv_with_timeout

tools/server/server-queue.cpp:289–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287}
288
289server_task_result_ptr server_response::recv_with_timeout(const std::unordered_set<int> & id_tasks, int timeout) {
290 while (true) {
291 std::unique_lock<std::mutex> lock(mutex_results);
292
293 for (int i = 0; i < (int) queue_results.size(); i++) {
294 if (id_tasks.find(queue_results[i]->id) != id_tasks.end()) {
295 server_task_result_ptr res = std::move(queue_results[i]);
296 queue_results.erase(queue_results.begin() + i);
297 return res;
298 }
299 }
300
301 std::cv_status cr_res = condition_results.wait_for(lock, std::chrono::seconds(timeout));
302 if (!running) {
303 RES_DBG("%s : queue result stop\n", __func__);
304 std::terminate(); // we cannot return here since the caller is HTTP code
305 }
306 if (cr_res == std::cv_status::timeout) {
307 return nullptr;
308 }
309 }
310
311 // should never reach here
312}
313
314server_task_result_ptr server_response::recv(int id_task) {
315 std::unordered_set<int> id_tasks = {id_task};

Callers 1

nextMethod · 0.80

Calls 4

findMethod · 0.80
endMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected