cpp-toolbox  0.0.1
A toolbox library for C++
Loading...
Searching...
No Matches
toolbox::base::thread_pool_t Class Reference

#include <thread_pool.hpp>

Public Member Functions

 thread_pool_t (size_t threads=0)
 
 ~thread_pool_t ()
 析构函数,停止线程池并等待所有工作线程完成/Destructor that stops the thread pool and waits for all worker threads to finish
 
size_t get_thread_count () const
 获取线程池中的工作线程数量/Get the number of worker threads
 
template<class F , class... Args>
auto submit (F &&f, Args &&... args) -> std::future< typename std::invoke_result_t< F, Args... > >
 

Constructor & Destructor Documentation

◆ thread_pool_t()

toolbox::base::thread_pool_t::thread_pool_t ( size_t  threads = 0)
explicit

◆ ~thread_pool_t()

toolbox::base::thread_pool_t::~thread_pool_t ( )

析构函数,停止线程池并等待所有工作线程完成/Destructor that stops the thread pool and waits for all worker threads to finish

等待线程已经取出的任务完成。析构后线程池将不可用/Waits for tasks already dequeued by threads to complete. After destruction, the thread pool becomes unusable

Member Function Documentation

◆ get_thread_count()

size_t toolbox::base::thread_pool_t::get_thread_count ( ) const
inline

获取线程池中的工作线程数量/Get the number of worker threads

Returns
当前工作线程数量/The current number of worker threads

◆ submit()

template<class F , class... Args>
auto toolbox::base::thread_pool_t::submit ( F &&  f,
Args &&...  args 
) -> std::future<typename std::invoke_result_t<F, Args...>>

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