ppsspp/ext/native/thread/executor.h
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

31 lines
596 B
C++

#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