Доделал Planner. Для компиляции тоже заменил старый Do на DoWithSchedule

Добавил сохранение в архив задач на компиляцию.
Закомментирова info txt который почему то в архив клался пустым, вместо него кладу в архив файлы TaskState и total_time.
Адаптировал анализ под распаковку архива.
При сохранении в бд, удаляю задачи на компиляцию.
This commit is contained in:
2023-12-04 01:43:08 +03:00
parent 39ee78da3d
commit 1f8ebdc9a2
9 changed files with 48 additions and 171 deletions

View File

@@ -60,7 +60,6 @@ public:
delete packedTasks;
delete lines;
}
void changeState() {
switch (this->state) {
case WorkspacesCreation:
@@ -81,60 +80,8 @@ public:
break;
}
}
void Do() {
saveState();
long activeCount = 0;
//todo обязательно убрать отладочную печать.
printf("tasks count = %ld\n", this->getLength());
while (this->state != End) {
// printf("state=%d\n", this->state);
// printf("max=%d; busy=%d; free=%d\n", maxKernels, busyKernels, freeKernels);
activeCount = 0;
for (long i = 0; i < this->getLength(); ++i) {
T* task = this->get(i);
switch (this->state) {
case WorkspacesCreation:
if (task->getState() == Waiting) {
activeCount++;
task->createWorkspace();
task->setState(WorkspaceCreated);
}
break;
case Preparation:
if (task->getState() == WorkspaceCreated) {
activeCount++;
task->prepareWorkspace();
task->createLaunchScript();
task->setState(WorkspaceReady);
}
break;
case Execution:
if (task->getState() == WorkspaceReady) {
activeCount++;
task->Start();
}
else if (task->getState() == Running) {
activeCount++;
task->Check();
}
break;
default:
// printf("id = %ld; state = %d\n", task->getId(), task->getState());
break;
}
}
// printf("active count = %d\n", activeCount);
if (activeCount == 0)
changeState();
Utils::Sleep(2);
}
}
void DoWithSchedule(int maxKernels) {
saveState();
// подготовка тестов
while (this->state != Execution) {
for (auto& task : this->getElements()) {
@@ -179,7 +126,7 @@ public:
String pathRes("results");
Utils::Mkdir(pathRes);
string buf;
//string buf;
while (activeTasks) {
long oldActiveTasks = activeTasks;
@@ -227,7 +174,7 @@ public:
busyKernels -= task->getKernels();
printf(" done task with %d kernels and id %ld\n", task->getKernels(), task->getId());
buf += to_string(task->getId()) + " " + string(task->printState().getCharArray()) + " " + to_string(task->getTotalTime()) + "\n";
//buf += to_string(task->getId()) + " " + string(task->printState().getCharArray()) + " " + to_string(task->getTotalTime()) + "\n";
task->copyResults(pathRes);
continue;
}
@@ -240,8 +187,8 @@ public:
changeState();
String outFile(pathRes + "/info.txt");
File tmp(outFile, String(buf.c_str()));
//String outFile(pathRes + "/info.txt");
//File tmp(outFile, String(buf.c_str()));
Utils::ZipFolder(pathRes, pathRes + ".zip");
}