Skip to content
Snippets Groups Projects
Threadpool.h 489 B
Newer Older
#include <condition_variable>
#include <functional>
#include <mutex>
#include <queue>

namespace util {

class Threadpool {
   public:
	// Constructor, Destructor
	Threadpool(size_t n);
	~Threadpool();
	// Add a task to the queue
	void queueTask(const std::function<void(void)>& task);
	void threading();
	std::vector<std::thread> threads;
	bool alive;
	std::queue<std::function<void(void)>> q;
	std::condition_variable cv;
	std::mutex m;
};
}  // namespace util