From bf83bb1e47ad57a343e19ac45e0617158ec81554 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 9 Mar 2020 18:25:32 -0700 Subject: [PATCH] http: Correct new thread executor. It needs to be able to handle N new threads, oops. --- ext/native/thread/executor.cpp | 7 ++++--- ext/native/thread/executor.h | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ext/native/thread/executor.cpp b/ext/native/thread/executor.cpp index e20fac09b1..0ae2b41b64 100644 --- a/ext/native/thread/executor.cpp +++ b/ext/native/thread/executor.cpp @@ -10,13 +10,14 @@ void SameThreadExecutor::Run(std::function func) { } void NewThreadExecutor::Run(std::function func) { - thread_ = std::thread(func); + threads_.push_back(std::thread(func)); } NewThreadExecutor::~NewThreadExecutor() { // If Run was ever called... - if (thread_.joinable()) - thread_.join(); + for (auto &thread : threads_) + thread.join(); + threads_.clear(); } } // namespace threading diff --git a/ext/native/thread/executor.h b/ext/native/thread/executor.h index 6a3122e920..44924952e6 100644 --- a/ext/native/thread/executor.h +++ b/ext/native/thread/executor.h @@ -2,6 +2,7 @@ #include #include +#include namespace threading { @@ -23,7 +24,7 @@ public: void Run(std::function func) override; private: - std::thread thread_; + std::vector threads_; }; } // namespace threading