@@ -303,7 +303,7 @@ void server_models::unload(const std::string & name) {
303303 std::lock_guard<std::mutex> lk (mutex);
304304 auto it = mapping.find (name);
305305 if (it != mapping.end ()) {
306- if (it->second .meta .status == SERVER_MODEL_STATUS_LOADED || it-> second . meta . status == SERVER_MODEL_STATUS_LOADING ) {
306+ if (it->second .meta .is_active () ) {
307307 SRV_INF (" unloading model instance name=%s\n " , name.c_str ());
308308 subprocess_destroy (it->second .subproc .get ());
309309 // status change will be handled by the managing thread
@@ -318,7 +318,7 @@ void server_models::unload_all() {
318318 {
319319 std::lock_guard<std::mutex> lk (mutex);
320320 for (auto & [name, inst] : mapping) {
321- if (inst.meta .status == SERVER_MODEL_STATUS_LOADED || inst. meta . status == SERVER_MODEL_STATUS_LOADING ) {
321+ if (inst.meta .is_active () ) {
322322 SRV_INF (" unloading model instance name=%s\n " , name.c_str ());
323323 subprocess_destroy (inst.subproc .get ());
324324 // status change will be handled by the managing thread
@@ -359,7 +359,7 @@ void server_models::ensure_model_loaded(const std::string & name) {
359359 if (!meta.has_value ()) {
360360 throw std::runtime_error (" model name=" + name + " is not found" );
361361 }
362- if (meta->status == SERVER_MODEL_STATUS_LOADED || meta-> status == SERVER_MODEL_STATUS_LOADING ) {
362+ if (meta->is_active () ) {
363363 return ; // already loaded
364364 }
365365 SRV_INF (" model name=%s is not loaded, loading...\n " , name.c_str ());
0 commit comments