MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / next

Method next

subprojects/llama.cpp/tools/server/server-queue.cpp:378–407  ·  view source on GitHub ↗

return nullptr if should_stop() is true before receiving a result note: if one error is received, it will stop further processing and return error result

Source from the content-addressed store, hash-verified

376// return nullptr if should_stop() is true before receiving a result
377// note: if one error is received, it will stop further processing and return error result
378server_task_result_ptr server_response_reader::next(const std::function<bool()> & should_stop) {
379 while (true) {
380 server_task_result_ptr result = queue_results.recv_with_timeout(id_tasks, polling_interval_seconds);
381 if (result == nullptr) {
382 // timeout, check stop condition
383 if (should_stop()) {
384 SRV_DBG("%s", "stopping wait for next result due to should_stop condition\n");
385 return nullptr;
386 }
387 } else {
388 if (result->is_error()) {
389 stop(); // cancel remaining tasks
390 SRV_DBG("%s", "received error result, stopping further processing\n");
391 return result;
392 }
393 if (!states.empty()) {
394 // update the generation state if needed
395 const size_t idx = result->index;
396 GGML_ASSERT(idx < states.size());
397 result->update(states[idx]);
398 }
399 if (result->is_stop()) {
400 received_count++;
401 }
402 return result;
403 }
404 }
405
406 // should not reach here
407}
408
409server_response_reader::batch_response server_response_reader::wait_for_all(const std::function<bool()> & should_stop) {
410 batch_response batch_res;

Callers

nothing calls this directly

Calls 8

should_stopFunction · 0.85
recv_with_timeoutMethod · 0.80
emptyMethod · 0.65
sizeMethod · 0.65
updateMethod · 0.65
stopFunction · 0.50
is_errorMethod · 0.45
is_stopMethod · 0.45

Tested by

no test coverage detected