improved planner
This commit is contained in:
@@ -157,10 +157,12 @@ public:
|
||||
vector<T*> toDel;
|
||||
|
||||
size_t done = 0;
|
||||
size_t step = ceil(totalProcessTasks * 0.02); // step == 2%
|
||||
size_t step = ceil(totalProcessTasks * 0.01); // step == 1%
|
||||
const double total = totalProcessTasks;
|
||||
|
||||
auto timer_start = Utils::getAbsoluteTime();
|
||||
auto timer_pause = Utils::getAbsoluteTime();
|
||||
auto timer_dump = Utils::getAbsoluteTime();
|
||||
|
||||
while (activeTasks) {
|
||||
long oldActiveTasks = activeTasks;
|
||||
emptyKeys.clear();
|
||||
@@ -221,19 +223,20 @@ public:
|
||||
#if DEB
|
||||
printf("done %ld / %d\n", done, this->getLength());
|
||||
#endif
|
||||
if ((done % step) == 0) {
|
||||
if ((done % step) == 0 && (Utils::getAbsoluteTime() - timer_dump) > 5) {
|
||||
size_t persentDone = (done / total) * 100.0;
|
||||
saveProgress(persentDone);
|
||||
timer_dump = Utils::getAbsoluteTime();
|
||||
}
|
||||
}
|
||||
|
||||
// прошло больше 10 секунд, проверяем паузу
|
||||
if (Utils::getAbsoluteTime() - timer_start > 30) {
|
||||
// прошло больше 30 секунд, проверяем паузу
|
||||
if (Utils::getAbsoluteTime() - timer_pause > 30) {
|
||||
printf("stoped\n");
|
||||
while (checkPause()) {
|
||||
Utils::Sleep(10);
|
||||
}
|
||||
timer_start = Utils::getAbsoluteTime();
|
||||
timer_pause = Utils::getAbsoluteTime();
|
||||
printf("resume\n");
|
||||
}
|
||||
}
|
||||
@@ -253,12 +256,17 @@ public:
|
||||
}
|
||||
|
||||
void saveProgress(long long persentDone) {
|
||||
FILE *f = fopen("progress", "w");
|
||||
String dump_progress = "echo '";
|
||||
dump_progress = dump_progress + to_string(persentDone).c_str() + "' >> progress";
|
||||
|
||||
system(dump_progress.getCharArray());
|
||||
|
||||
/*FILE* f = fopen("progress", "w");
|
||||
if (f) {
|
||||
fprintf(f, "%lld", persentDone);
|
||||
fflush(f);
|
||||
fclose(f);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
bool checkPause() {
|
||||
|
||||
@@ -1 +1 @@
|
||||
12
|
||||
13
|
||||
Reference in New Issue
Block a user