Files
VoidNet/include/ThreadPool.hpp
xX-TheDoctor-Xx a211400964 Added Development information for me to dont forget things xD
Added AllAndMe DistributionType
Added a ThreadPool class
Added VoidNetClientAPI
2016-07-18 01:13:20 +01:00

33 lines
570 B
C++

#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