|
| | thread_pool (const unsigned int &number_of_threads=std::thread::hardware_concurrency()) |
| |
| | ~thread_pool () |
| |
| | thread_pool (const thread_pool &)=delete |
| | thread pool is non-copyable
|
| |
| thread_pool & | operator= (const thread_pool &)=delete |
| |
template<typename Function , typename... Args, typename ReturnType = std::invoke_result_t<Function &&, Args &&...>>
requires std::invocable<Function, Args...> |
| std::future< ReturnType > | enqueue (Function f, Args... args) |
| | Enqueue a task into the thread pool that returns a result.
|
| |
template<typename Function , typename... Args>
requires std::invocable<Function, Args...> && std::is_same_v<void, std::invoke_result_t<Function &&, Args &&...>> |
| void | enqueue_detach (Function &&func, Args &&...args) |
| | Enqueue a task to be executed in the thread pool that returns void.
|
| |
| auto | size () const |
| |
template<typename FunctionType = details::default_function_type, typename ThreadType = std::jthread>
requires std::invocable<FunctionType> && std::is_same_v<void, std::invoke_result_t<FunctionType>>
class dp::thread_pool< FunctionType, ThreadType >
- Examples
- mandelbrot/source/main.cpp.
template<typename FunctionType = details::default_function_type, typename ThreadType = std::jthread>
template<typename Function , typename... Args, typename ReturnType = std::invoke_result_t<Function &&, Args &&...>>
requires std::invocable<Function, Args...>
| std::future< ReturnType > dp::thread_pool< FunctionType, ThreadType >::enqueue |
( |
Function |
f, |
|
|
Args... |
args |
|
) |
| |
|
inline |
Enqueue a task into the thread pool that returns a result.
Note that task execution begins once the task is enqueued.
- Template Parameters
-
| Function | An invokable type. |
| Args | Argument parameter pack |
| ReturnType | The return type of the Function |
- Parameters
-
| f | The callable function |
| args | The parameters that will be passed (copied) to the function. |
- Returns
- A std::future<ReturnType> that can be used to retrieve the returned value.
- Examples
- mandelbrot/source/main.cpp.
template<typename FunctionType = details::default_function_type, typename ThreadType = std::jthread>
template<typename Function , typename... Args>
requires std::invocable<Function, Args...> && std::is_same_v<void, std::invoke_result_t<Function &&, Args &&...>>
| void dp::thread_pool< FunctionType, ThreadType >::enqueue_detach |
( |
Function && |
func, |
|
|
Args &&... |
args |
|
) |
| |
|
inline |
Enqueue a task to be executed in the thread pool that returns void.
- Template Parameters
-
| Function | An invokable type. |
| Args | Argument parameter pack for Function |
- Parameters
-
| func | The callable to be executed |
| args | Arguments that will be passed to the function. |