summaryrefslogtreecommitdiff
path: root/src/threadengines/threadengine_pthread.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-02-10 14:50:38 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-02-10 14:50:38 +0000
commit11c08b9aed1792705e5d82b343fae6ce56910338 (patch)
tree31a3cb573ac3958dd9702dedce9d399da111e424 /src/threadengines/threadengine_pthread.cpp
parenteedce11c9606f24d339d8055fd9d0f995b4e0951 (diff)
Each Thread class must have its own thread handle, duh. Someone take away my craqpipe NOW.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8876 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/threadengines/threadengine_pthread.cpp')
-rw-r--r--src/threadengines/threadengine_pthread.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/threadengines/threadengine_pthread.cpp b/src/threadengines/threadengine_pthread.cpp
index c35388cdf..da120bfab 100644
--- a/src/threadengines/threadengine_pthread.cpp
+++ b/src/threadengines/threadengine_pthread.cpp
@@ -36,14 +36,17 @@ void PThreadEngine::Create(Thread* thread_to_init)
{
pthread_attr_t attribs;
pthread_attr_init(&attribs);
- if (pthread_create(&this->MyPThread,
- &attribs,
- PThreadEngine::Entry,
- (void*)this) != 0)
+ pthread_t* MyPThread = new pthread_t;
+
+ if (pthread_create(MyPThread, &attribs, PThreadEngine::Entry, (void*)this) != 0)
{
+ delete MyPThread;
throw CoreException("Unable to create new PThreadEngine: " + std::string(strerror(errno)));
}
+
NewThread = thread_to_init;
+ NewThread->Creator = this;
+ NewThread->Extend("pthread", MyPThread);
}
PThreadEngine::~PThreadEngine()
@@ -53,9 +56,6 @@ PThreadEngine::~PThreadEngine()
void PThreadEngine::Run()
{
- /* This is a factory function that will create a class of type 'Thread'. The class of type Thread just
- * takes an InspIRCd* pointer and a ThreadEngine* pointer in its ctor (so it can easily use the Mutex
- * methods etc) and runs asyncronously of the ircd. */
NewThread->Run();
}
@@ -76,3 +76,12 @@ void* PThreadEngine::Entry(void* parameter)
return NULL;
}
+void PThreadEngine::FreeThread(Thread* thread)
+{
+ pthread_t* pthread = NULL;
+ if (thread->GetExt("pthread", pthread))
+ {
+ delete pthread;
+ }
+}
+