summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/threadengine.h2
-rw-r--r--src/threadengine.cpp9
2 files changed, 2 insertions, 9 deletions
diff --git a/include/threadengine.h b/include/threadengine.h
index b240c1bbf..79cca6c61 100644
--- a/include/threadengine.h
+++ b/include/threadengine.h
@@ -26,7 +26,7 @@ private:
public:
/* Handle for this thread */
- std::thread *handle = nullptr;
+ std::unique_ptr<std::thread> handle;
/** Threads destructor
*/
diff --git a/src/threadengine.cpp b/src/threadengine.cpp
index 569eb2e80..a2af55e87 100644
--- a/src/threadengine.cpp
+++ b/src/threadengine.cpp
@@ -18,8 +18,6 @@ static void *entry_point(void *parameter)
Thread *thread = static_cast<Thread *>(parameter);
thread->Run();
thread->SetExitState();
- delete thread->handle;
- thread->handle = nullptr;
return NULL;
}
@@ -39,11 +37,6 @@ void Thread::SetExitState()
void Thread::Exit()
{
this->SetExitState();
- if (this->handle)
- {
- delete this->handle;
- this->handle = nullptr;
- }
}
void Thread::Start()
@@ -51,7 +44,7 @@ void Thread::Start()
try
{
if (!this->handle)
- this->handle = new std::thread(entry_point, this);
+ this->handle = std::make_unique<std::thread>(entry_point, this);
}
catch (const std::system_error& err)
{