#include "./file_inactivity_system.hpp" #include #include #include "./components.hpp" #include namespace Systems { void file_inactivity( ObjectRegistry& os_reg, float current_time ) { std::vector to_close; size_t total {0}; os_reg.view().each([&os_reg, &to_close, &total, current_time](Object ov, const Components::FT1File2& ft_f) { if (current_time - ft_f.last_activity_ts >= 30.f) { // after 30sec of inactivity to_close.push_back(ov); } total++; }); if (!to_close.empty()) { std::cout << "SHA1_NGCFT1: closing " << to_close.size() << " out of " << total << " open files\n"; os_reg.remove(to_close.cbegin(), to_close.cend()); } } } // Systems