Maurice Grönwoldt
5bb68a7d02
We have no make install support... so we don't need to have everything as a single-header and lib file.
27 lines
550 B
C++
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
|