17 #ifndef LUNCHBOX_THREADPOOL_H 18 #define LUNCHBOX_THREADPOOL_H 20 #include <condition_variable> 45 const size_t size = std::max(1u, std::thread::hardware_concurrency()));
62 inline std::future<typename std::result_of<F()>::type>
post(F&& f);
77 inline void joinAll();
80 std::vector<std::thread> _threads;
81 std::queue<std::function<void()> > _tasks;
82 mutable std::mutex _mutex;
83 std::condition_variable _condition;
88 #include "threadPool.ipp" 90 #endif // LUNCHBOX_THREADPOOL_H Thread pool for tasks execution.
bool hasPendingJobs() const
~ThreadPool()
Destroy this thread pool.
std::future< typename std::result_of< F()>::type > post(F &&f)
Post a new task in the thread pool.
ThreadPool(const size_t size=std::max(1u, std::thread::hardware_concurrency()))
Construct a ThreadPool.
void postDetached(F &&f)
Post a detached task in the thread pool.
Abstraction layer and common utilities for multi-threaded programming.