| 686 | } |
| 687 | } |
| 688 | // `loading` itself will occupy one slot, so at most limit - 1 others may stay. |
| 689 | int to_evict = static_cast<int>(resident.size()) - (limit - 1); |
| 690 | if (to_evict <= 0) { |
| 691 | return; |
| 692 | } |
| 693 | std::sort(resident.begin(), resident.end(), [](const LoadedModel * a, const LoadedModel * b) { |
| 694 | return a->last_used_ms.load(std::memory_order_relaxed) < |
| 695 | b->last_used_ms.load(std::memory_order_relaxed); |
| 696 | }); |
| 697 | for (LoadedModel * victim : resident) { |
| 698 | if (to_evict == 0) { |
| 699 | return; |
| 700 | } |
nothing calls this directly
no test coverage detected