Add initial sleep for background processing functions

This commit is contained in:
Simon Quigley 2025-01-29 14:55:37 -06:00
parent bb3d45c4ea
commit 2c82ddf9f3

View File

@ -288,6 +288,9 @@ void ensure_git_inited() {
}
void run_task_every(std::stop_token _stop_token, int interval_minutes, std::function<void()> task) {
if (interval_minutes < 2) interval_minutes = 2;
std::this_thread::sleep_for(std::chrono::minutes(interval_minutes / 2));
while (!_stop_token.stop_requested()) {
task();
std::this_thread::sleep_for(std::chrono::minutes(interval_minutes));