http: Correct new thread executor.

It needs to be able to handle N new threads, oops.
This commit is contained in:
Unknown W. Brackets committed 2020-03-09 19:57:15 -07:00
1 parent e97e3c4218
commit bf83bb1e47
2 files changed
+6 -4

No files matched your search

+4 -3
View File
@@ -10,13 +10,14 @@ void SameThreadExecutor::Run(std::function<void()> func) {
}
void NewThreadExecutor::Run(std::function<void()> 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