|
LMMS
|
A thread pool that can be used for asynchronous processing. More...
#include <ThreadPool.h>
Public Member Functions | |
| ~ThreadPool () | |
| template<typename Fn, typename... Args> | |
| auto | enqueue (Fn &&fn, Args &&... args) -> std::future< std::invoke_result_t< Fn, Args... > > |
| Enqueue function fn with arguments args to be ran asynchronously. | |
| auto | numWorkers () const -> size_t |
| Return the number of worker threads used. | |
Static Public Member Functions | |
| static auto | instance () -> ThreadPool & |
| Return the global ThreadPool instance. | |
Private Member Functions | |
| ThreadPool (size_t numWorkers) | |
| void | run () |
Private Attributes | |
| std::vector< std::thread > | m_workers |
| std::queue< std::function< void()> > | m_queue |
| std::atomic< bool > | m_done = false |
| std::condition_variable | m_runCond |
| std::mutex | m_runMutex |
Static Private Attributes | |
| static size_t | s_numWorkers = std::thread::hardware_concurrency() |
A thread pool that can be used for asynchronous processing.
| lmms::ThreadPool::~ThreadPool | ( | ) |
Destroys the ThreadPool object. This blocks until all workers have finished executing.
|
private |
|
inline |
Enqueue function fn with arguments args to be ran asynchronously.
|
static |
Return the global ThreadPool instance.
| auto lmms::ThreadPool::numWorkers | ( | ) | const -> size_t |
Return the number of worker threads used.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
inlinestaticprivate |