Common: Get rid of Executor.cpp/h.

There was only one implementation.
This commit is contained in:
Henrik Rydgård authored and Unknown W. Brackets committed 2021-04-30 22:33:34 -07:00
1 parent 8c72cc119e
commit e6aa841b78
12 files changed
+25 -79

No files matched your search

-23
View File
@@ -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
-30
View File
@@ -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