diff options
Diffstat (limited to 'include/mbgl/util/threadpool.hpp')
-rw-r--r-- | include/mbgl/util/threadpool.hpp | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/include/mbgl/util/threadpool.hpp b/include/mbgl/util/threadpool.hpp deleted file mode 100644 index 497d4e3083..0000000000 --- a/include/mbgl/util/threadpool.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef MBGL_UTIL_THREADPOOL -#define MBGL_UTIL_THREADPOOL - -#include <pthread.h> -#include <forward_list> -#include <queue> - -namespace mbgl { -namespace util { - -class Threadpool { -private: - class Worker { - public: - Worker(Threadpool& pool); - ~Worker(); - static void *loop(void *ptr); - - private: - Threadpool& pool; - pthread_t thread; - }; - -public: - Threadpool(int max_workers = 4); - typedef void (*Callback)(void *); - void add(Callback callback, void *data); - -private: - typedef std::pair<Callback, void *> Task; - const int max_workers; - pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - pthread_cond_t condition = PTHREAD_COND_INITIALIZER; - std::forward_list<Worker> workers; - int worker_count = 0; - std::queue<Task> tasks; -}; - -extern std::unique_ptr<Threadpool> threadpool; - -} -} - -#endif - |