summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/threadengine.h4
-rw-r--r--src/threadengine.cpp4
-rw-r--r--src/threadengines/threadengine_pthread.cpp9
-rw-r--r--src/threadengines/threadengine_win32.cpp9
4 files changed, 6 insertions, 20 deletions
diff --git a/include/threadengine.h b/include/threadengine.h
index 39f150566..e656eb6b3 100644
--- a/include/threadengine.h
+++ b/include/threadengine.h
@@ -49,11 +49,11 @@ class CoreExport Thread
public:
/** Opaque thread state managed by threading engine
*/
- ThreadData* state;
+ ThreadData state;
/** Set Creator to NULL at this point
*/
- Thread() : ExitFlag(false), state(NULL)
+ Thread() : ExitFlag(false)
{
}
diff --git a/src/threadengine.cpp b/src/threadengine.cpp
index 4269c1aef..82aa78a36 100644
--- a/src/threadengine.cpp
+++ b/src/threadengine.cpp
@@ -26,9 +26,7 @@ void Thread::SetExitFlag()
void Thread::join()
{
- state->FreeThread(this);
- delete state;
- state = 0;
+ state.FreeThread(this);
}
/** If this thread has a Creator set, call it to
diff --git a/src/threadengines/threadengine_pthread.cpp b/src/threadengines/threadengine_pthread.cpp
index 36ba3ab42..7900e66bc 100644
--- a/src/threadengines/threadengine_pthread.cpp
+++ b/src/threadengines/threadengine_pthread.cpp
@@ -39,15 +39,8 @@ static void* entry_point(void* parameter)
void ThreadEngine::Start(Thread* thread)
{
- ThreadData* data = new ThreadData;
- thread->state = data;
-
- if (pthread_create(&data->pthread_id, NULL, entry_point, thread) != 0)
- {
- thread->state = NULL;
- delete data;
+ if (pthread_create(&thread->state.pthread_id, NULL, entry_point, thread) != 0)
throw CoreException("Unable to create new thread: " + std::string(strerror(errno)));
- }
}
void ThreadData::FreeThread(Thread* thread)
diff --git a/src/threadengines/threadengine_win32.cpp b/src/threadengines/threadengine_win32.cpp
index 77f638f37..3376f937a 100644
--- a/src/threadengines/threadengine_win32.cpp
+++ b/src/threadengines/threadengine_win32.cpp
@@ -23,17 +23,12 @@
void ThreadEngine::Start(Thread* thread)
{
- ThreadData* data = new ThreadData;
- thread->state = data;
-
DWORD ThreadId = 0;
- data->handle = CreateThread(NULL,0,ThreadEngine::Entry,thread,0,&ThreadId);
+ thread->state.handle = CreateThread(NULL, 0, ThreadEngine::Entry, thread, 0, &ThreadId);
- if (data->handle == NULL)
+ if (thread->state.handle == NULL)
{
DWORD lasterr = GetLastError();
- thread->state = NULL;
- delete data;
std::string err = "Unable to create new thread: " + ConvToStr(lasterr);
SetLastError(ERROR_SUCCESS);
throw CoreException(err);