diff --git a/include/actsim_agent/task_interface.hpp b/include/actsim_agent/task_interface.hpp index 906366c..0746f6c 100644 --- a/include/actsim_agent/task_interface.hpp +++ b/include/actsim_agent/task_interface.hpp @@ -42,10 +42,10 @@ using OutputType = pl::SimOutputArtifact; class TaskInterface { - public: TaskInterface(size_t buffer_size); + ~TaskInterface(); void wait_for_fresh(); void wait_for_finished(); diff --git a/src/actsim_agent/task_interface.cpp b/src/actsim_agent/task_interface.cpp index a7e421f..24c2066 100644 --- a/src/actsim_agent/task_interface.cpp +++ b/src/actsim_agent/task_interface.cpp @@ -29,6 +29,13 @@ TaskInterface::TaskInterface(size_t buffer_size) { this->buffer_size = buffer_size; } +TaskInterface::~TaskInterface() { + bool empty = false; + while (!empty) this->pop_fresh(empty); + empty = false; + while (!empty) this->pop_finished(empty); +} + void TaskInterface::push_fresh(std::unique_ptr task) { // lock the queue and insert into it