Add a new task to the end of the queue
| 1565 | |
| 1566 | // Add a new task to the end of the queue |
| 1567 | int post(server_task && task, bool front = false) { |
| 1568 | std::unique_lock<std::mutex> lock(mutex_tasks); |
| 1569 | GGML_ASSERT(task.id != -1); |
| 1570 | // if this is cancel task make sure to clean up pending tasks |
| 1571 | if (task.type == SERVER_TASK_TYPE_CANCEL) { |
| 1572 | cleanup_pending_task(task.id_target); |
| 1573 | } |
| 1574 | const int task_id = task.id; |
| 1575 | QUE_DBG("new task, id = %d, front = %d\n", task_id, front); |
| 1576 | if (front) { |
| 1577 | queue_tasks.push_front(std::move(task)); |
| 1578 | } else { |
| 1579 | queue_tasks.push_back(std::move(task)); |
| 1580 | } |
| 1581 | condition_tasks.notify_one(); |
| 1582 | return task_id; |
| 1583 | } |
| 1584 | |
| 1585 | // multi-task version of post() |
| 1586 | int post(std::vector<server_task> && tasks, bool front = false) { |
no test coverage detected