VulcanoLE/headers/VUtils/Pool.h

26 lines
547 B
C
Raw Normal View History

2021-02-20 18:13:51 +01:00
#pragma once
#include <functional>
#include <thread>
namespace VUtils {
struct PoolWorker {
virtual void run() = 0;
};
class Pool {
public:
explicit Pool(const char *name);
~Pool();
void setThreadCount(int count);
void create(PoolWorker& worker);
void joinFirstThread();
protected:
bool m_isCreated = false;
int m_count = 1;
const char *m_name = "Pool";
PoolWorker *m_worker{};
std::thread *m_threads{};
void execute();
};
}