mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 21:39:52 +00:00
bf83bb1e47
It needs to be able to handle N new threads, oops.
31 lines
596 B
C++
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
|