# My Project: utils::ThreadPool Class Reference

Loading...
Searching...
No Matches
utils::ThreadPool Class Reference

`#include <ThreadPool.hh>`

Collaboration diagram for utils::ThreadPool:

## Public Member Functions

| ThreadPool (std::size_t threads=std::thread::hardware_concurrency())
| ~ThreadPool ()
template<class F, class... Args>
auto | enqueue (F &&f, Args &&... args) -> std::future< std::invoke_result_t< F, Args... > >

## Private Attributes

std::vector< std::thread > | _workers
std::queue< std::function< void()> > | _tasks
std::mutex | _queue_mutex
std::condition_variable | _cv
bool | _stop {false}

## Constructor & Destructor Documentation

## ThreadPool()

utils::ThreadPool::ThreadPool | ( | std::size_t | threads = std::thread::hardware_concurrency() | ) |

explicit

References _cv, _queue_mutex, _stop, _tasks, and _workers.

## ~ThreadPool()

utils::ThreadPool::~ThreadPool | ( |  | ) |

References _cv, _queue_mutex, _stop, and _workers.

## Member Function Documentation

## enqueue()

template<class F, class... Args>

auto utils::ThreadPool::enqueue | ( | F && | f,
|  | Args &&... | args ) -> std::future<std::invoke_result_t<F, Args...>>

inline

References _cv, _queue_mutex, _stop, and _tasks.

## Member Data Documentation

## _cv

std::condition_variable utils::ThreadPool::_cv

private

Referenced by enqueue(), ThreadPool(), and ~ThreadPool().

## _queue_mutex

std::mutex utils::ThreadPool::_queue_mutex

private

Referenced by enqueue(), ThreadPool(), and ~ThreadPool().

## _stop

bool utils::ThreadPool::_stop {false}

private

Referenced by enqueue(), ThreadPool(), and ~ThreadPool().

## _tasks

std::queue<std::function<void()> > utils::ThreadPool::_tasks

private

Referenced by enqueue(), and ThreadPool().

## _workers

std::vector<std::thread> utils::ThreadPool::_workers

private

Referenced by ThreadPool(), and ~ThreadPool().

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

- include/utils/ThreadPool.hh
- src/utils/ThreadPool.cc