From 268c5327459377e11dbfed4e57a28c2154fb112d Mon Sep 17 00:00:00 2001 From: Fabian Posch Date: Thu, 11 Jan 2024 16:01:53 -0500 Subject: [PATCH] fix sigsev at program close by adding destructor at program close --- include/actsim_agent/task_interface.hpp | 2 +- src/actsim_agent/task_interface.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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