From 66b96b90d51a31600a18ac6c6fa20875cb7eb24a Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Fri, 2 Aug 2013 08:31:07 -0700 Subject: [PATCH] Generate a fatal error if a running Thread object is destroyed --- TODO.txt | 2 -- modules/beast_core/threads/beast_Thread.cpp | 3 ++- modules/beast_core/threads/beast_Thread.h | 5 +---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/TODO.txt b/TODO.txt index 211334626..cfee8af9b 100644 --- a/TODO.txt +++ b/TODO.txt @@ -4,8 +4,6 @@ BEAST TODO - add expectThrow() to UnitTest, where it expects an exception -- Remove timeout forced-kill from Thread::stopThread () - - Import secp256k1 from sipa - HashMap work: diff --git a/modules/beast_core/threads/beast_Thread.cpp b/modules/beast_core/threads/beast_Thread.cpp index 0a5fffae4..8e5e41f98 100644 --- a/modules/beast_core/threads/beast_Thread.cpp +++ b/modules/beast_core/threads/beast_Thread.cpp @@ -42,7 +42,8 @@ Thread::~Thread() */ bassert (! isThreadRunning()); - stopThread (100); + if (isThreadRunning()) + FatalError ("Thread is still running", __FILE__, __LINE__); } //============================================================================== diff --git a/modules/beast_core/threads/beast_Thread.h b/modules/beast_core/threads/beast_Thread.h index 2a3027264..0315ab44e 100644 --- a/modules/beast_core/threads/beast_Thread.h +++ b/modules/beast_core/threads/beast_Thread.h @@ -56,10 +56,7 @@ public: /** Destructor. - Deleting a Thread object that is running will only give the thread a - brief opportunity to stop itself cleanly, so it's recommended that you - should always call stopThread() with a decent timeout before deleting, - to avoid the thread being forcibly killed (which is a Bad Thing). + If the thread has not been stopped first, this will generate a fatal error. */ virtual ~Thread();