mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-29 09:13:39 +01:00
Common: Get rid of Executor.cpp/h.
There was only one implementation.
This commit is contained in:
1 parent
8c72cc119e
commit
e6aa841b78
12 files changed
+25
-79
No files matched your search
@@ -1,23 +0,0 @@
|
||||
#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
|
||||
@@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
namespace threading {
|
||||
|
||||
// Stuff that can execute other stuff, like threadpools, should inherit from this.
|
||||
class Executor {
|
||||
public:
|
||||
virtual void Run(std::function<void()> func) = 0;
|
||||
virtual ~Executor() {}
|
||||
};
|
||||
|
||||
class SameThreadExecutor : public Executor {
|
||||
public:
|
||||
void Run(std::function<void()> func) override;
|
||||
};
|
||||
|
||||
class NewThreadExecutor : public Executor {
|
||||
public:
|
||||
~NewThreadExecutor() override;
|
||||
void Run(std::function<void()> func) override;
|
||||
|
||||
private:
|
||||
std::vector<std::thread> threads_;
|
||||
};
|
||||
|
||||
} // namespace threading
|
||||
Reference in new issue
Block a user