Task Pool that can run any callable object.
This class is general purpose thread pool that can launch task asyncronously. It is possible to get an asyncronous result of a task execution.
task_pool(const unsigned int num_threads = std::thread::hardware_concurrency())¶
Creates assts::task_pool instance with the given number of threads.
num_threads: Number of threads that will be used in the underlying ssts::task_pool.
Destructs this after all joinable threads are terminated.
Stop all threads.
Stop thread pool and join all joinable threads.
run(FunctionType &&f, const std::optional<size_t> &task_hash = std::nullopt)¶
Run a callable object asynchronously.
Enqueue a new task with the given callable object. The enqueued task will run as soon as a thread is available. Returns the result of the asynchronous computation.
std::future task result
- Template Parameters
FunctionType: Types of the callable object.
f: Callable object.
- inline explicit