fixed task completeness was not checked before upload

This commit is contained in:
Fabian Posch 2024-01-09 21:27:39 -05:00
parent e85ce57b82
commit a5a989b359
2 changed files with 8 additions and 7 deletions

View file

@ -46,7 +46,7 @@ class Worker {
private:
void thread_run();
void perform_task(std::unique_ptr<Task>& task, bool& success);
bool perform_task(std::unique_ptr<Task>& task);
std::unique_ptr<std::thread> worker_thread;
std::atomic<db::uuid_t> current_task;

View file

@ -60,17 +60,18 @@ void Worker::thread_run() {
if (queue_empty) continue;
// everything is good, perform the given task
bool success;
this->perform_task(task, success);
bool complete = this->perform_task(task);
// if everything worked, push the task to be uploaded
this->interface.push_finished(std::move(task));
// if the task was finished, push the task to be uploaded
// we need this since the task might have been interrupted
// half way though
if (complete) this->interface.push_finished(std::move(task));
}
}
void Worker::perform_task(std::unique_ptr<Task>& task, bool& success) {
bool Worker::perform_task(std::unique_ptr<Task>& task) {
std::cout << "Worker ping" << std::endl;
usleep(100000);
success = true;
task->get_uuid();
return true;
}