From 8235290c734c17f5b52533876136e9a61d231c9d Mon Sep 17 00:00:00 2001 From: danieldg Date: Mon, 10 Aug 2009 19:55:07 +0000 Subject: Fix thread join not working for subclasses of Thread because of C++ destructor ordering git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11500 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/threadengine.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'include/threadengine.h') diff --git a/include/threadengine.h b/include/threadengine.h index c11f2d817..10f3fed13 100644 --- a/include/threadengine.h +++ b/include/threadengine.h @@ -30,7 +30,7 @@ class ThreadData; * code. Be sure to keep your code thread-safe and not prone to deadlocks * and race conditions if you MUST use threading! */ -class CoreExport Thread : public Extensible +class CoreExport Thread { private: /** Set to true when the thread is to exit @@ -55,6 +55,7 @@ class CoreExport Thread : public Extensible { } + /* If the thread is running, you MUST join BEFORE deletion */ virtual ~Thread(); /** Override this method to put your actual @@ -64,10 +65,11 @@ class CoreExport Thread : public Extensible /** Signal the thread to exit gracefully. */ - virtual void SetExitFlag() - { - ExitFlag = true; - } + virtual void SetExitFlag(); + + /** Join the thread (calls SetExitFlag and waits for exit) + */ + void join(); }; -- cgit v1.3.1-10-gc9f91