fixed task completeness was not checked before upload
This commit is contained in:
parent
e85ce57b82
commit
a5a989b359
2 changed files with 8 additions and 7 deletions
|
|
@ -46,7 +46,7 @@ class Worker {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void thread_run();
|
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::unique_ptr<std::thread> worker_thread;
|
||||||
std::atomic<db::uuid_t> current_task;
|
std::atomic<db::uuid_t> current_task;
|
||||||
|
|
|
||||||
|
|
@ -60,17 +60,18 @@ void Worker::thread_run() {
|
||||||
if (queue_empty) continue;
|
if (queue_empty) continue;
|
||||||
|
|
||||||
// everything is good, perform the given task
|
// everything is good, perform the given task
|
||||||
bool success;
|
bool complete = this->perform_task(task);
|
||||||
this->perform_task(task, success);
|
|
||||||
|
|
||||||
// if everything worked, push the task to be uploaded
|
// if the task was finished, push the task to be uploaded
|
||||||
this->interface.push_finished(std::move(task));
|
// 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;
|
std::cout << "Worker ping" << std::endl;
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
success = true;
|
|
||||||
task->get_uuid();
|
task->get_uuid();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue