batmat 0.0.16
Batched linear algebra routines
Loading...
Searching...
No Matches
batmat::thread_pool Class Reference

#include <batmat/thread-pool.hpp>

Detailed Description

Definition at line 16 of file thread-pool.hpp.

Classes

struct  Signals

Public Member Functions

 thread_pool (size_t num_threads=std::thread::hardware_concurrency())
 thread_pool (const thread_pool &)=delete
thread_pooloperator= (const thread_pool &)=delete
 thread_pool (thread_pool &&)=default
thread_pooloperator= (thread_pool &&)=default
void schedule (size_t i, std::function< void()> func)
void wait (size_t i)
void wait_all ()
template<class I = size_t, class F>
void sync_run_all (F &&f)
template<class I = size_t, class F>
void sync_run_n (I n, F &&f)
size_t size () const

Private Member Functions

void work (std::stop_token stop, size_t i)

Private Attributes

std::vector< Signalssignals
std::vector< std::function< void()> > funcs
std::vector< std::exception_ptr > exceptions
std::vector< std::jthread > threads

Class Documentation

◆ batmat::thread_pool::Signals

struct batmat::thread_pool::Signals
Class Members
mutex mtx
condition_variable_any cv

Constructor & Destructor Documentation

◆ thread_pool() [1/3]

batmat::thread_pool::thread_pool ( size_t num_threads = std::thread::hardware_concurrency())
inlineexplicit

Definition at line 48 of file thread-pool.hpp.

◆ thread_pool() [2/3]

batmat::thread_pool::thread_pool ( const thread_pool & )
delete

◆ thread_pool() [3/3]

batmat::thread_pool::thread_pool ( thread_pool && )
default

Member Function Documentation

◆ work()

void batmat::thread_pool::work ( std::stop_token stop,
size_t i )
inlineprivate

Definition at line 27 of file thread-pool.hpp.

◆ operator=() [1/2]

thread_pool & batmat::thread_pool::operator= ( const thread_pool & )
delete

◆ operator=() [2/2]

thread_pool & batmat::thread_pool::operator= ( thread_pool && )
default

◆ schedule()

void batmat::thread_pool::schedule ( size_t i,
std::function< void()> func )
inline

Definition at line 61 of file thread-pool.hpp.

◆ wait()

void batmat::thread_pool::wait ( size_t i)
inline

Definition at line 69 of file thread-pool.hpp.

◆ wait_all()

void batmat::thread_pool::wait_all ( )
inline

Definition at line 77 of file thread-pool.hpp.

◆ sync_run_all()

template<class I = size_t, class F>
void batmat::thread_pool::sync_run_all ( F && f)
inline

Definition at line 83 of file thread-pool.hpp.

◆ sync_run_n()

template<class I = size_t, class F>
void batmat::thread_pool::sync_run_n ( I n,
F && f )
inline

Definition at line 91 of file thread-pool.hpp.

◆ size()

size_t batmat::thread_pool::size ( ) const
inlinenodiscard

Definition at line 100 of file thread-pool.hpp.

Member Data Documentation

◆ signals

std::vector<Signals> batmat::thread_pool::signals
private

Definition at line 22 of file thread-pool.hpp.

◆ funcs

std::vector<std::function<void()> > batmat::thread_pool::funcs
private

Definition at line 23 of file thread-pool.hpp.

◆ exceptions

std::vector<std::exception_ptr> batmat::thread_pool::exceptions
private

Definition at line 24 of file thread-pool.hpp.

◆ threads

std::vector<std::jthread> batmat::thread_pool::threads
private

Definition at line 25 of file thread-pool.hpp.


The documentation for this class was generated from the following file: