Implement thread_ctrl::wait_until()

This commit is contained in:
Elad Ashkenazi 2024-08-16 20:06:20 +03:00
parent b2877365de
commit 1bd4565186
6 changed files with 47 additions and 11 deletions

View file

@ -175,7 +175,9 @@ void progress_dialog_server::operator()()
usz time_left_queue_idx = 0;
// Update progress
while (!g_system_progress_stopping && thread_ctrl::state() != thread_state::aborting)
for (u64 sleep_until = get_system_time(), sleep_for = 500;
!g_system_progress_stopping && thread_ctrl::state() != thread_state::aborting;
thread_ctrl::wait_until(&sleep_until, std::exchange(sleep_for, 500)))
{
const auto& [text_new, ftotal_new, fdone_new, ftotal_bits_new, fknown_bits_new, ptotal_new, pdone_new] = get_state();
@ -236,7 +238,7 @@ void progress_dialog_server::operator()()
}
}
thread_ctrl::wait_for(10000);
sleep_for = 10000;
continue;
}
@ -365,7 +367,7 @@ void progress_dialog_server::operator()()
break;
}
thread_ctrl::wait_for(10'000);
sleep_for = 10'000;
wait_no_update_count++;
}