From 97b65b2255d538ed8a45d82d64452723d24d5753 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 25 Feb 2024 21:54:40 +0000 Subject: Use unique_ptr for managing std::thread ownership. --- src/threadengine.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/threadengine.cpp') 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(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(entry_point, this); } catch (const std::system_error& err) { -- cgit