26 lines
547 B
C++
26 lines
547 B
C++
#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();
|
|
};
|
|
} |