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