From 6b7bafc1483f045c64312635e830ee1f8a3b4746 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 22 Feb 2008 18:42:21 +0000 Subject: Thread safety stuff, waiting for pointer to become 'safe' before changing it (e.g. to launch another thread) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9007 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/threadengines/threadengine_pthread.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/threadengines/threadengine_pthread.cpp b/src/threadengines/threadengine_pthread.cpp index d6b0f3bd7..6a48bd025 100644 --- a/src/threadengines/threadengine_pthread.cpp +++ b/src/threadengines/threadengine_pthread.cpp @@ -44,6 +44,9 @@ void PThreadEngine::Create(Thread* thread_to_init) NewThread->Extend("pthread", MyPThread); Mutex(false); + + while (NewThread) + usleep(1000); } PThreadEngine::~PThreadEngine() @@ -52,7 +55,11 @@ PThreadEngine::~PThreadEngine() void PThreadEngine::Run() { - NewThread->Run(); + Mutex(true); + Thread* nt = NewThread; + NewThread = NULL; + Mutex(false); + nt->Run(); } bool PThreadEngine::Mutex(bool enable) -- cgit v1.2.3