A thread pool that can be used for asynchronous processing.
More...
#include <ThreadPool.h>
|
| | ~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 size_t | s_numWorkers = std::thread::hardware_concurrency() |
A thread pool that can be used for asynchronous processing.
◆ ~ThreadPool()
| lmms::ThreadPool::~ThreadPool |
( |
| ) |
|
Destroys the ThreadPool object. This blocks until all workers have finished executing.
◆ ThreadPool()
| lmms::ThreadPool::ThreadPool |
( |
size_t | numWorkers | ) |
|
|
private |
◆ enqueue()
template<typename Fn, typename... Args>
| auto lmms::ThreadPool::enqueue |
( |
Fn && | fn, |
|
|
Args &&... | args ) -> std::future< std::invoke_result_t< Fn, Args... > > |
|
inline |
Enqueue function fn with arguments args to be ran asynchronously.
◆ instance()
| auto lmms::ThreadPool::instance |
( |
| ) |
-> ThreadPool & |
|
static |
◆ numWorkers()
| auto lmms::ThreadPool::numWorkers |
( |
| ) |
const -> size_t |
Return the number of worker threads used.
◆ run()
| void lmms::ThreadPool::run |
( |
| ) |
|
|
private |
◆ m_done
| std::atomic<bool> lmms::ThreadPool::m_done = false |
|
private |
◆ m_queue
| std::queue<std::function<void()> > lmms::ThreadPool::m_queue |
|
private |
◆ m_runCond
| std::condition_variable lmms::ThreadPool::m_runCond |
|
private |
◆ m_runMutex
| std::mutex lmms::ThreadPool::m_runMutex |
|
private |
◆ m_workers
| std::vector<std::thread> lmms::ThreadPool::m_workers |
|
private |
◆ s_numWorkers
| size_t lmms::ThreadPool::s_numWorkers = std::thread::hardware_concurrency() |
|
inlinestaticprivate |
The documentation for this class was generated from the following files: