diff --git a/include/cactus_rt/thread.h b/include/cactus_rt/thread.h index 3cef2ec..5fe4234 100644 --- a/include/cactus_rt/thread.h +++ b/include/cactus_rt/thread.h @@ -98,7 +98,7 @@ class Thread { // The constructors and destructors are needed because we need to delete // objects of type Thread polymorphically, through the map in the App class. - virtual ~Thread() = default; + virtual ~Thread(); // Copy constructors are not allowed Thread(const Thread&) = delete; diff --git a/src/cactus_rt/thread.cc b/src/cactus_rt/thread.cc index 0342bb2..97fcea0 100644 --- a/src/cactus_rt/thread.cc +++ b/src/cactus_rt/thread.cc @@ -78,4 +78,11 @@ void Thread::Start(int64_t start_monotonic_time_ns, App* app) { int Thread::Join() const { return pthread_join(thread_, nullptr); } + +Thread::~Thread() { + if (app_ != nullptr) { + app_->DeregisterThreadTracer(tracer_); + } +} + } // namespace cactus_rt