tfel
Loading...
Searching...
No Matches
tfel::system::ThreadPool Struct Reference

structure handling a fixed-size pool of threads More...

#include </home/runner/work/tfel/tfel/include/TFEL/System/ThreadPool.hxx>

Public Types

using size_type = std::vector<std::thread>::size_type
 a simple alias

Public Member Functions

 ThreadPool (const size_type)
 constructor
template<typename F, typename... Args>
std::future< ThreadedTaskResult< std::invoke_result_t< F, Args... > > > addTask (F &&, Args &&...)
 add a new task
size_type getNumberOfThreads () const
void wait ()
 wait for all tasks to be finished
 ~ThreadPool ()
 destructor
template<typename F, typename... Args>
std::future< ThreadedTaskResult< std::invoke_result_t< F, Args... > > > addTask (F &&f, Args &&... a)

Detailed Description

structure handling a fixed-size pool of threads

Constructor & Destructor Documentation

◆ ThreadPool()

tfel::system::ThreadPool::ThreadPool ( const size_type )
explicit

constructor

Parameters
[in]nnumber of thread to be created

Member Function Documentation

◆ addTask()

template<typename F, typename... Args>
std::future< ThreadedTaskResult< std::invoke_result_t< F, Args... > > > tfel::system::ThreadPool::addTask ( F && ,
Args && ... )
nodiscard

add a new task

Parameters
[in]ftask
[in]aarguments passed to the the task

◆ getNumberOfThreads()

size_type tfel::system::ThreadPool::getNumberOfThreads ( ) const
nodiscard
Returns
the number of threads managed by the ppol

The documentation for this struct was generated from the following files: