neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
neolib::thread_pool Class Reference

#include <thread_pool.hpp>

Classes

struct  no_threads
 
struct  task_not_found
 

Public Types

typedef std::shared_ptr< i_tasktask_pointer
 

Public Member Functions

 thread_pool ()
 
 ~thread_pool ()
 
void reserve (std::size_t aMaxThreads)
 
std::size_t active_threads () const
 
std::size_t available_threads () const
 
std::size_t total_threads () const
 
std::size_t max_threads () const
 
void start (i_task &aTask, int32_t aPriority=0)
 
void start (task_pointer aTask, int32_t aPriority=0)
 
bool try_start (i_task &aTask, int32_t aPriority=0)
 
bool try_start (task_pointer aTask, int32_t aPriority=0)
 
std::pair< std::future< void >, task_pointerrun (std::function< void()> aFunction, int32_t aPriority=0)
 
template<typename T >
std::pair< std::future< T >, task_pointerrun (std::function< T()> aFunction, int32_t aPriority=0)
 
bool idle () const
 
void update_idle ()
 
bool busy () const
 
void wait () const
 
bool stopped () const
 
void stop ()
 
std::recursive_mutex & mutex () const
 

Static Public Member Functions

static thread_pooldefault_thread_pool ()
 

Friends

class thread_pool_thread
 

Detailed Description

Definition at line 52 of file thread_pool.hpp.

Member Typedef Documentation

◆ task_pointer

Definition at line 56 of file thread_pool.hpp.

Constructor & Destructor Documentation

◆ thread_pool()

neolib::thread_pool::thread_pool ( )

◆ ~thread_pool()

neolib::thread_pool::~thread_pool ( )

Member Function Documentation

◆ active_threads()

std::size_t neolib::thread_pool::active_threads ( ) const

◆ available_threads()

std::size_t neolib::thread_pool::available_threads ( ) const

◆ busy()

bool neolib::thread_pool::busy ( ) const

◆ default_thread_pool()

static thread_pool & neolib::thread_pool::default_thread_pool ( )
static

◆ idle()

bool neolib::thread_pool::idle ( ) const

◆ max_threads()

std::size_t neolib::thread_pool::max_threads ( ) const

◆ mutex()

std::recursive_mutex & neolib::thread_pool::mutex ( ) const

◆ reserve()

void neolib::thread_pool::reserve ( std::size_t  aMaxThreads)

◆ run() [1/2]

template<typename T >
std::pair< std::future< T >, thread_pool::task_pointer > neolib::thread_pool::run ( std::function< T()>  aFunction,
int32_t  aPriority = 0 
)
inline

Definition at line 104 of file thread_pool.hpp.

◆ run() [2/2]

std::pair< std::future< void >, task_pointer > neolib::thread_pool::run ( std::function< void()>  aFunction,
int32_t  aPriority = 0 
)

◆ start() [1/2]

void neolib::thread_pool::start ( i_task aTask,
int32_t  aPriority = 0 
)

◆ start() [2/2]

void neolib::thread_pool::start ( task_pointer  aTask,
int32_t  aPriority = 0 
)

◆ stop()

void neolib::thread_pool::stop ( )

◆ stopped()

bool neolib::thread_pool::stopped ( ) const

◆ total_threads()

std::size_t neolib::thread_pool::total_threads ( ) const

◆ try_start() [1/2]

bool neolib::thread_pool::try_start ( i_task aTask,
int32_t  aPriority = 0 
)

◆ try_start() [2/2]

bool neolib::thread_pool::try_start ( task_pointer  aTask,
int32_t  aPriority = 0 
)

◆ update_idle()

void neolib::thread_pool::update_idle ( )

◆ wait()

void neolib::thread_pool::wait ( ) const

Friends And Related Symbol Documentation

◆ thread_pool_thread

friend class thread_pool_thread
friend

Definition at line 54 of file thread_pool.hpp.


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