Add initial sleep for background processing functions
This commit is contained in:
parent
bb3d45c4ea
commit
2c82ddf9f3
@ -288,6 +288,9 @@ void ensure_git_inited() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void run_task_every(std::stop_token _stop_token, int interval_minutes, std::function<void()> task) {
|
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()) {
|
while (!_stop_token.stop_requested()) {
|
||||||
task();
|
task();
|
||||||
std::this_thread::sleep_for(std::chrono::minutes(interval_minutes));
|
std::this_thread::sleep_for(std::chrono::minutes(interval_minutes));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user