ppsspp/Common/Thread/Executor.cpp

24 lines
441 B
C++
Raw Normal View History

#include "Common/Thread/Executor.h"
#include <functional>
2018-04-12 20:30:12 -07:00
#include <thread>
namespace threading {
void SameThreadExecutor::Run(std::function<void()> func) {
2018-04-12 20:30:12 -07:00
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