summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-02-22 18:42:21 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-02-22 18:42:21 +0000
commit6b7bafc1483f045c64312635e830ee1f8a3b4746 (patch)
treecc35262459f74d2378f2181684edba41c9863083 /src
parent1c2b47abadc0907c4642557910b6480150f279d2 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/threadengines/threadengine_pthread.cpp9
1 files changed, 8 insertions, 1 deletions
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)