X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fthread.cpp;h=810b1f80485197eeb66552707897c89e42356215;hb=c2eeec205dbf17f6ca38fda2671c6aaf2d1c505f;hp=8e1134b80fa2e68ade849c5bff6033af3b6a2c25;hpb=521cf1db00f8ce2d9f9494dca503d6c17d89ac2f;p=libs%2Fcore.git diff --git a/source/core/thread.cpp b/source/core/thread.cpp index 8e1134b..810b1f8 100644 --- a/source/core/thread.cpp +++ b/source/core/thread.cpp @@ -4,6 +4,7 @@ This file is part of libmspcore Copyright © 2006 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ + #ifndef WIN32 #include #endif @@ -25,7 +26,7 @@ void Thread::join() #else pthread_join(thread_, 0); #endif - launched_=false; + launched_ = false; } /** @@ -53,7 +54,10 @@ void Thread::kill() Thread::~Thread() { if(launched_) + { kill(); + join(); + } } void Thread::launch() @@ -63,11 +67,11 @@ void Thread::launch() #ifdef WIN32 DWORD dummy; // Win9x needs the lpTthreadId parameter - thread_=CreateThread(0, 0, &main_, this, 0, &dummy); + thread_ = CreateThread(0, 0, &main_, this, 0, &dummy); #else pthread_create(&thread_, 0, &main_, this); #endif - launched_=true; + launched_ = true; } } // namespace Msp