server: Initialize standby_timeout over constructor instead of passing as argument

This commit is contained in:
johannes 2024-12-11 08:33:24 +01:00
parent acbac00f0d
commit 4fd58a8013

View file

@ -1179,6 +1179,8 @@ struct server_queue {
std::function<void(server_task)> callback_new_task; std::function<void(server_task)> callback_new_task;
std::function<void(void)> callback_update_slots; std::function<void(void)> callback_update_slots;
int standby_timeout;
// Add a new task to the end of the queue // Add a new task to the end of the queue
int post(server_task task, bool front = false) { int post(server_task task, bool front = false) {
std::unique_lock<std::mutex> lock(mutex_tasks); std::unique_lock<std::mutex> lock(mutex_tasks);
@ -1260,7 +1262,7 @@ struct server_queue {
* - Check if multitask is finished * - Check if multitask is finished
* - Update all slots * - Update all slots
*/ */
void start_loop(int standby_timeout) { void start_loop() {
running = true; running = true;
while (true) { while (true) {
@ -1428,6 +1430,10 @@ struct server_context {
// Necessary similarity of prompt for slot selection // Necessary similarity of prompt for slot selection
float slot_prompt_similarity = 0.0f; float slot_prompt_similarity = 0.0f;
server_context() {
queue_tasks.standby_timeout = params_base.standby_timeout;
}
~server_context() { ~server_context() {
if (ctx) { if (ctx) {
llama_free(ctx); llama_free(ctx);
@ -3952,7 +3958,7 @@ int main(int argc, char ** argv) {
LOG_INF("%s: server is listening on http://%s:%d - starting the main loop\n", __func__, params.hostname.c_str(), params.port); LOG_INF("%s: server is listening on http://%s:%d - starting the main loop\n", __func__, params.hostname.c_str(), params.port);
ctx_server.queue_tasks.start_loop(params.standby_timeout); ctx_server.queue_tasks.start_loop();
#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) #if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
struct sigaction sigint_action; struct sigaction sigint_action;