VWeb/Includes/ThreadPool.h
Maurice Grönwoldt 5bb68a7d02 Split VWeb into smaller headers
We have no make install support... so we don't need to have everything as a single-header and lib file.
2023-09-16 16:29:03 +02:00

27 lines
550 B
C++

#pragma once
#include "Queue.h"
#include "Types.h"
namespace VWeb {
struct WorkerJob {
virtual ~WorkerJob() = default;
virtual void Execute() = 0;
};
class ThreadPool {
public:
explicit ThreadPool(std::string name);
void SetThreadCount(int);
void Dispatch(const Ref<WorkerJob> &);
void Create();
void Stop();
void Execute();
protected:
std::string m_Name;
int m_ThreadCount{1};
bool m_IsCreated{false};
std::vector<std::thread> m_Threads{};
SafeQueue<Ref<WorkerJob>> m_Queue;
bool m_IsDone{false};
};
} // namespace VWeb