From eb15a35ecbe2acd3437cff474686df8fde9bf42a Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Fri, 26 Aug 2016 02:06:27 +0800 Subject: Replace std::unique(new T()) with make_unique(). This commit modernize the code base by replacing: std::unique_ptr(new T(...)) with: make_unique(...) or: wasm::make_unique(...) This is a step closer to adopt C++14 std::make_unique(...). --- src/support/threads.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/support/threads.cpp') diff --git a/src/support/threads.cpp b/src/support/threads.cpp index d9e8f8bf2..18f99d5ca 100644 --- a/src/support/threads.cpp +++ b/src/support/threads.cpp @@ -22,6 +22,7 @@ #include "threads.h" #include "compiler-support.h" +#include "utilities.h" // debugging tools @@ -47,7 +48,7 @@ static std::unique_ptr pool; Thread::Thread() { assert(!ThreadPool::get()->isRunning()); - thread = std::unique_ptr(new std::thread(mainLoop, this)); + thread = make_unique(mainLoop, this); } Thread::~Thread() { @@ -110,7 +111,7 @@ void ThreadPool::initialize(size_t num) { ready.store(threads.size()); // initial state before first resetThreadsAreReady() resetThreadsAreReady(); for (size_t i = 0; i < num; i++) { - threads.emplace_back(std::unique_ptr(new Thread())); + threads.emplace_back(make_unique()); } DEBUG_POOL("initialize() waiting\n"); condition.wait(lock, [this]() { return areThreadsReady(); }); @@ -127,7 +128,7 @@ size_t ThreadPool::getNumCores() { ThreadPool* ThreadPool::get() { if (!pool) { - pool = std::unique_ptr(new ThreadPool()); + pool = make_unique(); pool->initialize(getNumCores()); } return pool.get(); -- cgit v1.2.3