Worker threads running tasks by priority, then in submission order.
More...
#include <RST/threads/ThreadPool.hpp>
Worker threads running tasks by priority, then in submission order.
Worker threads running tasks by priority, then in submission order.
Definition ThreadPool.hpp:24
◆ Priority
Higher priorities run first.
| Enumerator |
|---|
| Low | |
| Normal | |
| High | |
◆ ThreadPool() [1/3]
| RST::Threads::ThreadPool::ThreadPool |
( |
std::size_t |
numThreads = std::thread::hardware_concurrency(), |
|
|
std::string_view |
name = "ThreadPool" |
|
) |
| |
Starts numThreads workers, named after name in debuggers on Linux and macOS.
- Exceptions
-
| std::invalid_argument | if numThreads is 0. |
◆ ~ThreadPool()
| RST::Threads::ThreadPool::~ThreadPool |
( |
| ) |
|
Runs the queued tasks, then joins the workers.
◆ ThreadPool() [2/3]
| RST::Threads::ThreadPool::ThreadPool |
( |
const ThreadPool & |
| ) |
|
|
delete |
◆ ThreadPool() [3/3]
| RST::Threads::ThreadPool::ThreadPool |
( |
ThreadPool && |
| ) |
|
|
delete |
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ submit()
template<typename F , typename... Args>
Queues fn(args...) and returns a std::future of its result.
- Exceptions
-
| std::runtime_error | if the pool is being destroyed. |
◆ pause()
| void RST::Threads::ThreadPool::pause |
( |
| ) |
|
|
noexcept |
Stops starting new tasks; running tasks finish.
◆ resume()
| void RST::Threads::ThreadPool::resume |
( |
| ) |
|
|
noexcept |
◆ isPaused()
| bool RST::Threads::ThreadPool::isPaused |
( |
| ) |
const |
|
noexcept |
◆ waitForAll()
| void RST::Threads::ThreadPool::waitForAll |
( |
| ) |
|
Blocks until every queued task has run; do not call it while paused.
◆ workerCount()
| std::size_t RST::Threads::ThreadPool::workerCount |
( |
| ) |
const |
|
inlinenoexcept |
◆ name()
| std::string_view RST::Threads::ThreadPool::name |
( |
| ) |
const |
|
inlinenoexcept |
The documentation for this class was generated from the following file: