mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-29 21:28:37 +01:00
Move threading utils from native to Common
This commit is contained in:
1 parent
ef08c0237f
commit
15382d5f94
61 files changed
+105
-138
No files matched your search
@@ -0,0 +1,23 @@
|
||||
#include "Common/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
|
||||
Reference in new issue
Block a user