From 4149afd45d2c0b9f464d1b4434f7bdaa61873d44 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 9 May 2010 17:50:53 -0400 Subject: [PATCH] Changed threadengine to delete threads after Joining them, so the whole thread exists when being joined and so its safe to call non-threadsafe functions in the destructor --- src/threadengine.cpp | 1 - src/threadengine_pthread.cpp | 3 ++- src/threadengine_win32.cpp | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/threadengine.cpp b/src/threadengine.cpp index f7e924fb6..ea652e1f2 100644 --- a/src/threadengine.cpp +++ b/src/threadengine.cpp @@ -12,7 +12,6 @@ Thread::Thread() : Exit(false) */ Thread::~Thread() { - Join(); } /** Sets the exit state as true informing the thread we want it to shut down diff --git a/src/threadengine_pthread.cpp b/src/threadengine_pthread.cpp index 58b3a11ac..199bd0860 100644 --- a/src/threadengine_pthread.cpp +++ b/src/threadengine_pthread.cpp @@ -6,6 +6,7 @@ void Thread::Join() { SetExitState(); pthread_join(Handle, NULL); + delete this; } /* Threadengine attributes used by this thread engine */ @@ -18,7 +19,7 @@ static void *entry_point(void *parameter) { Thread *thread = static_cast(parameter); thread->Run(); - return parameter; + pthread_exit(0); } /** Threadengines constructor diff --git a/src/threadengine_win32.cpp b/src/threadengine_win32.cpp index 602d8b809..d3c0303f5 100644 --- a/src/threadengine_win32.cpp +++ b/src/threadengine_win32.cpp @@ -6,6 +6,7 @@ void Thread::Join() { SetExitState(); WaitForSingleObject(Handle, INFINITE); + delete this; } /** Entry point for the thread