| 726 | } |
| 727 | |
| 728 | void server_models::unload_all() { |
| 729 | std::vector<std::thread> to_join; |
| 730 | { |
| 731 | std::lock_guard<std::mutex> lk(mutex); |
| 732 | for (auto & [name, inst] : mapping) { |
| 733 | if (inst.meta.is_running()) { |
| 734 | SRV_INF("stopping model instance name=%s\n", name.c_str()); |
| 735 | stopping_models.insert(name); |
| 736 | cv_stop.notify_all(); |
| 737 | // status change will be handled by the managing thread |
| 738 | } |
| 739 | // moving the thread to join list to avoid deadlock |
| 740 | to_join.push_back(std::move(inst.th)); |
| 741 | } |
| 742 | } |
| 743 | for (auto & th : to_join) { |
| 744 | if (th.joinable()) { |
| 745 | th.join(); |
| 746 | } |
| 747 | } |
| 748 | } |
| 749 | |
| 750 | void server_models::update_status(const std::string & name, server_model_status status, int exit_code) { |
| 751 | std::unique_lock<std::mutex> lk(mutex); |
no test coverage detected