ppsspp/ext/native/thread/executor.cpp
Unknown W. Brackets bf83bb1e47 http: Correct new thread executor.
It needs to be able to handle N new threads, oops.
2020-03-09 19:57:15 -07:00

23 lines
434 B
C++

#include "thread/executor.h"
#include <functional>
#include <thread>
namespace threading {
void SameThreadExecutor::Run(std::function<void()> func) {
func();
}
void NewThreadExecutor::Run(std::function<void()> func) {
threads_.push_back(std::thread(func));
}
NewThreadExecutor::~NewThreadExecutor() {
// If Run was ever called...
for (auto &thread : threads_)
thread.join();
threads_.clear();
}
} // namespace threading