From 1cee069243fe6996d9fb05b4cd4cd466a78abda1 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 12 May 2019 10:46:08 +0200 Subject: [PATCH] added warning when deleting a thread that isnot finished --- libretroshare/src/util/rsthreads.cc | 10 ++++++++++ libretroshare/src/util/rsthreads.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/util/rsthreads.cc b/libretroshare/src/util/rsthreads.cc index 297629a43..ceaf57368 100644 --- a/libretroshare/src/util/rsthreads.cc +++ b/libretroshare/src/util/rsthreads.cc @@ -103,6 +103,16 @@ RsThread::RsThread() mShouldStopSemaphore.set(0) ; } +RsThread::~RsThread() +{ + if(isRunning()) + { + std::cerr << "(EE) Deleting a thread that is actually running! Something is very wrong here:" << std::endl; + + print_stacktrace(); + } +} + bool RsThread::isRunning() { // do we need a mutex for this ? diff --git a/libretroshare/src/util/rsthreads.h b/libretroshare/src/util/rsthreads.h index d9c82792a..15c776e64 100644 --- a/libretroshare/src/util/rsthreads.h +++ b/libretroshare/src/util/rsthreads.h @@ -243,7 +243,7 @@ class RsThread { public: RsThread(); - virtual ~RsThread() {} + virtual ~RsThread() ; void start(const std::string &threadName = "");