From c35571e37bdd6d2fe9b95e4265c150265585f3a9 Mon Sep 17 00:00:00 2001 From: drumsetmonkey Date: Wed, 30 Mar 2016 08:41:16 -0400 Subject: Inv and textures --- include/threadpool.hpp | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 include/threadpool.hpp (limited to 'include/threadpool.hpp') diff --git a/include/threadpool.hpp b/include/threadpool.hpp new file mode 100644 index 0000000..c341673 --- /dev/null +++ b/include/threadpool.hpp @@ -0,0 +1,53 @@ +#ifndef THREADPOOL_H +#define THREADPOOL_H + +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +class ThreadPool +{ +public: + + // Constructor. + ThreadPool(int threads); + + // Destructor. + ~ThreadPool(); + + // Adds task to a task queue. + void Enqueue(function f); + + // Shut down the pool. + void ShutDown(); + +private: + // Thread pool storage. + vector threadPool; + + // Queue to keep track of incoming tasks. + queue> tasks; + + // Task queue mutex. + mutex tasksMutex; + + // Condition variable. + condition_variable condition; + + // Indicates that pool needs to be shut down. + bool terminate; + + // Indicates that pool has been terminated. + bool stopped; + + // Function that will be invoked by our threads. + void Invoke(); +}; + +#endif //THRE \ No newline at end of file -- cgit v1.2.3