summaryrefslogtreecommitdiff
path: root/src/threadengines
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-06-24 12:45:21 +0200
committerAttila Molnar <attilamolnar@hush.com>2014-06-24 12:45:21 +0200
commit36b9b4b39900d1b2e3b182e1b50370b0c9dcb9ae (patch)
tree0d6f84597c4e103647de04eea4eb0c21ce6ef9c2 /src/threadengines
parentaa7df4b8234d4b601ad0310605181fdabc8cfcaa (diff)
Change allocation of ThreadData to be physically part of the object containing it
Diffstat (limited to 'src/threadengines')
-rw-r--r--src/threadengines/threadengine_pthread.cpp9
-rw-r--r--src/threadengines/threadengine_win32.cpp9
2 files changed, 3 insertions, 15 deletions
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);