diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-08-26 10:13:48 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-26 10:13:48 -0700 |
commit | 801baed1ca81d87380d56298289fe8cc0b4f1e1a (patch) | |
tree | 683c8535f4e6072e41eda4fcda08e00da42b6626 /src/support/threads.cpp | |
parent | 2cb8b275caf090bf56cc78424aaa97766cd02fb6 (diff) | |
parent | a008d4fd7af3b04a3d351a03d56df7c28998690e (diff) | |
download | binaryen-801baed1ca81d87380d56298289fe8cc0b4f1e1a.tar.gz binaryen-801baed1ca81d87380d56298289fe8cc0b4f1e1a.tar.bz2 binaryen-801baed1ca81d87380d56298289fe8cc0b4f1e1a.zip |
Merge pull request #682 from loganchien/fix-empty-deadlock
Fix asm2wasm dead lock caused by empty module
Diffstat (limited to 'src/support/threads.cpp')
-rw-r--r-- | src/support/threads.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
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<ThreadPool> pool; Thread::Thread() { assert(!ThreadPool::get()->isRunning()); - thread = std::unique_ptr<std::thread>(new std::thread(mainLoop, this)); + thread = make_unique<std::thread>(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<Thread>(new Thread())); + threads.emplace_back(make_unique<Thread>()); } 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<ThreadPool>(new ThreadPool()); + pool = make_unique<ThreadPool>(); pool->initialize(getNumCores()); } return pool.get(); |