Doxygen
|
Class managing a pool of worker threads. More...
#include <src/threadpool.h>
Public Member Functions | |
ThreadPool (std::size_t N=1) | |
start N threads in the thread pool. | |
~ThreadPool () | |
deletes the thread pool by finishing all threads | |
ThreadPool (const ThreadPool &)=delete | |
ThreadPool & | operator= (const ThreadPool &)=delete |
ThreadPool (ThreadPool &&)=delete | |
ThreadPool & | operator= (ThreadPool &&)=delete |
template<class F, typename ... Args> | |
auto | queue (F &&f, Args &&... args) -> std::future< decltype(f(args...))> |
Queue the callable function f for the threads to execute. | |
void | finish () |
finish enques a "stop the thread" message for every thread, then waits for them to finish | |
Private Member Functions | |
void | threadTask () |
Private Attributes | |
std::mutex | m_mutex |
std::condition_variable | m_cond |
std::deque< std::function< void()> > | m_work |
std::vector< std::future< void > > | m_finished |
Class managing a pool of worker threads.
Work can be queued by passing a function to queue(). A future will be returned that can be used to obtain the result of the function after execution.
Usage example:
Definition at line 47 of file threadpool.h.
|
inline |
start N threads in the thread pool.
Definition at line 51 of file threadpool.h.
References m_finished, and threadTask().
Referenced by operator=(), operator=(), ThreadPool(), and ThreadPool().
|
inline |
deletes the thread pool by finishing all threads
Definition at line 65 of file threadpool.h.
References finish().
|
delete |
References ThreadPool().
|
delete |
References ThreadPool().
|
inline |
finish enques a "stop the thread" message for every thread, then waits for them to finish
Definition at line 100 of file threadpool.h.
References m_cond, m_finished, m_mutex, and m_work.
Referenced by ~ThreadPool().
|
delete |
References ThreadPool().
|
delete |
References ThreadPool().
|
inline |
Queue the callable function f for the threads to execute.
A future of the return type of the function is returned to capture the result.
Definition at line 77 of file threadpool.h.
References m_cond, m_mutex, and m_work.
Referenced by computeTooltipTexts(), FormulaManager::createFormulasTexFile(), generateDocsForClassList(), generateFileDocs(), generateFileSources(), generateJSTreeFiles(), generateNamespaceClassDocs(), parseFilesMultiThreading(), and writeJavaScriptSearchIndex().
|
inlineprivate |
Definition at line 116 of file threadpool.h.
References m_cond, m_mutex, and m_work.
Referenced by ThreadPool().
|
private |
Definition at line 142 of file threadpool.h.
Referenced by finish(), queue(), and threadTask().
|
private |
Definition at line 148 of file threadpool.h.
Referenced by finish(), and ThreadPool().
|
private |
Definition at line 141 of file threadpool.h.
Referenced by finish(), queue(), and threadTask().
|
private |
Definition at line 145 of file threadpool.h.
Referenced by finish(), queue(), and threadTask().