Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ThreadPool Class Reference

#include <timer.h>

Public Member Functions

void _thread_process (void)
 
template<typename callable , class... arguments>
void commit (callable &&f, arguments &&...args)
 
template<typename callable , class... arguments>
void dispatch (callable &&f, arguments &&...args)
 
void set_max_thread_count (int max_thread_count)
 
void stop ()
 
 ThreadPool (int max_thread_count=10)
 
 ~ThreadPool ()
 

Static Public Member Functions

static void thread_handle (void *arg)
 

Private Types

using Task = std::function< void()>
 

Private Member Functions

void _thread_check (void)
 

Private Attributes

int free_thread_count_
 
int max_thread_count_
 
std::mutex mutex_
 
std::vector< std::thread > pool_
 
std::atomic< bool > stoped_
 
std::condition_variable task_cond_
 
std::queue< Tasktask_que_
 
int total_thread_count_
 

Detailed Description

Definition at line 103 of file timer.h.

Member Typedef Documentation

using ThreadPool::Task = std::function<void()>
private

Definition at line 193 of file timer.h.

Constructor & Destructor Documentation

ThreadPool::ThreadPool ( int  max_thread_count = 10)
inline

Definition at line 105 of file timer.h.

ThreadPool::~ThreadPool ( )
inline

Definition at line 106 of file timer.h.

Member Function Documentation

void ThreadPool::_thread_check ( void  )
inlineprivate

Definition at line 186 of file timer.h.

void ThreadPool::_thread_process ( void  )
inline

Definition at line 115 of file timer.h.

template<typename callable , class... arguments>
void ThreadPool::commit ( callable &&  f,
arguments &&...  args 
)
inline

Definition at line 179 of file timer.h.

template<typename callable , class... arguments>
void ThreadPool::dispatch ( callable &&  f,
arguments &&...  args 
)
inline

Definition at line 165 of file timer.h.

void ThreadPool::set_max_thread_count ( int  max_thread_count)
inline

Definition at line 160 of file timer.h.

void ThreadPool::stop ( )
inline

Definition at line 149 of file timer.h.

static void ThreadPool::thread_handle ( void *  arg)
inlinestatic

Definition at line 110 of file timer.h.

Member Data Documentation

int ThreadPool::free_thread_count_
private

Definition at line 201 of file timer.h.

int ThreadPool::max_thread_count_
private

Definition at line 199 of file timer.h.

std::mutex ThreadPool::mutex_
private

Definition at line 196 of file timer.h.

std::vector<std::thread> ThreadPool::pool_
private

Definition at line 195 of file timer.h.

std::atomic<bool> ThreadPool::stoped_
private

Definition at line 202 of file timer.h.

std::condition_variable ThreadPool::task_cond_
private

Definition at line 197 of file timer.h.

std::queue<Task> ThreadPool::task_que_
private

Definition at line 194 of file timer.h.

int ThreadPool::total_thread_count_
private

Definition at line 200 of file timer.h.


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


xarm_api
Author(s):
autogenerated on Sat May 8 2021 02:51:23