Go to the documentation of this file.
16 #ifndef SURGSIM_FRAMEWORK_THREADPOOL_H
17 #define SURGSIM_FRAMEWORK_THREADPOOL_H
20 #include <boost/thread.hpp>
70 explicit ThreadPool(
size_t numThreads = boost::thread::hardware_concurrency());
82 std::future<R>
enqueue(std::function<R()>
function);
102 std::queue<std::unique_ptr<TaskBase>>
m_tasks;
119 #endif //SURGSIM_FRAMEWORK_THREADPOOL_H
Actual tasks, with typed return type.
Definition: ThreadPool-inl.h:34
std::list< boost::thread > m_threads
The worker threads.
Definition: ThreadPool.h:96
Definition: ThreadPool-inl.h:25
std::atomic< bool > m_destructing
True if the ThreadPool is destructing.
Definition: ThreadPool.h:111
~ThreadPool()
Desctructor.
Definition: ThreadPool.cpp:54
Definition: CompoundShapeToGraphics.cpp:29
boost::mutex m_mutex
Mutex for protecting the tasks queue.
Definition: ThreadPool.h:105
A thread pool for completing heterogenous tasks.
Definition: ThreadPool.h:65
boost::condition_variable m_threadSignaler
Signaler for waking up threads waiting for tasks.
Definition: ThreadPool.h:108
std::future< R > enqueue(std::function< R()> function)
Queue a task to be run by the ThreadPool.
Definition: ThreadPool-inl.h:57
ThreadPool(size_t numThreads=boost::thread::hardware_concurrency())
Constructor.
Definition: ThreadPool.cpp:24
std::queue< std::unique_ptr< TaskBase > > m_tasks
Queued tasks waiting for an available thread.
Definition: ThreadPool.h:102
ThreadPool & operator=(const ThreadPool &other)