summaryrefslogtreecommitdiff
path: root/src/threadengine_win32.cpp
diff options
context:
space:
mode:
authorAdam <Adam@drink-coca-cola.info>2010-05-09 19:02:50 -0400
committerAdam <Adam@anope.org>2010-06-18 21:01:09 -0400
commit4e1286ca109d079f32d32f07c344a1ab93899032 (patch)
treeef55488a4cc068f8954a8862ab2e67f2d1872281 /src/threadengine_win32.cpp
parent4149afd45d2c0b9f464d1b4434f7bdaa61873d44 (diff)
Rewrote the mail system to use threading
Diffstat (limited to 'src/threadengine_win32.cpp')
-rw-r--r--src/threadengine_win32.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/threadengine_win32.cpp b/src/threadengine_win32.cpp
index d3c0303f5..5ee2f4596 100644
--- a/src/threadengine_win32.cpp
+++ b/src/threadengine_win32.cpp
@@ -1,14 +1,5 @@
#include "services.h"
-/** Join to the thread, sets the exit state to true
- */
-void Thread::Join()
-{
- SetExitState();
- WaitForSingleObject(Handle, INFINITE);
- delete this;
-}
-
/** Entry point for the thread
* @param paramter A Thread* cast to a void*
*/
@@ -16,6 +7,11 @@ static DWORD WINAPI entry_point(void *parameter)
{
Thread *thread = static_cast<Thread *>(parameter);
thread->Run();
+ if (!thread->GetExitState())
+ {
+ thread->Join();
+ }
+ delete thread;
return 0;
}
@@ -31,6 +27,14 @@ ThreadEngine::~ThreadEngine()
{
}
+/** Join to the thread, sets the exit state to true
+ */
+void Thread::Join()
+{
+ SetExitState();
+ WaitForSingleObject(Handle, INFINITE);
+}
+
/** Start a new thread
* @param thread A pointer to a newley allocated thread
*/
@@ -41,7 +45,7 @@ void ThreadEngine::Start(Thread *thread)
if (!thread->Handle)
{
delete thread;
- throw CoreException("Unable to create thread");
+ throw CoreException("Unable to create thread: " + std::string(dlerror()));
}
}