Added Development information for me to dont forget things xD
Added AllAndMe DistributionType Added a ThreadPool class Added VoidNetClientAPI
This commit is contained in:
33
include/ThreadPool.hpp
Normal file
33
include/ThreadPool.hpp
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef THREAD_POOL_HPP
|
||||
#define THREAD_POOL_HPP
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
|
||||
class ThreadPool
|
||||
{
|
||||
public:
|
||||
ThreadPool(int threads);
|
||||
~ThreadPool();
|
||||
void Enqueue(std::function<void()> f);
|
||||
void Shutdown();
|
||||
const ThreadPool &operator=(ThreadPool &pool);
|
||||
|
||||
private:
|
||||
std::vector<std::thread> threadPool;
|
||||
std::queue<std::function<void()>> tasks;
|
||||
std::mutex tasksMutex;
|
||||
std::condition_variable condition;
|
||||
bool terminate;
|
||||
bool stopped;
|
||||
void Invoke();
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user