mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-28 16:53:40 +01:00
Merge pull request #12697 from unknownbrackets/http
http: Correct new thread executor
This commit is contained in:
2 files changed
+6
-4
No files matched your search
@@ -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
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
namespace threading {
|
||||
|
||||
@@ -23,7 +24,7 @@ public:
|
||||
void Run(std::function<void()> func) override;
|
||||
|
||||
private:
|
||||
std::thread thread_;
|
||||
std::vector<std::thread> threads_;
|
||||
};
|
||||
|
||||
} // namespace threading
|
||||
Reference in new issue
Block a user