#include <ThreadPool.h>

Public Member Functions

 ThreadPool (size_t=0)
 
template<class F , class... Args>
auto enqueue (F &&f, Args &&... args) -> std::future< typename std::invoke_result< F, Args... >::type >
 
size_t workerCount () const
 
 ~ThreadPool ()
 

Private Attributes

std::vector< std::thread > workers
 
std::queue< std::function< void()> > tasks
 
std::mutex queue_mutex
 
std::condition_variable condition
 
bool stop
 

Constructor & Destructor Documentation

◆ ThreadPool()

ThreadPool::ThreadPool ( size_t  threads = 0)
inline

◆ ~ThreadPool()

ThreadPool::~ThreadPool ( )
inline

Member Function Documentation

◆ enqueue()

template<class F , class... Args>
auto ThreadPool::enqueue ( F &&  f,
Args &&...  args 
) -> std::future<typename std::invoke_result<F,Args...>::type>

◆ workerCount()

size_t ThreadPool::workerCount ( ) const
inline

Member Data Documentation

◆ condition

std::condition_variable ThreadPool::condition
private

◆ queue_mutex

std::mutex ThreadPool::queue_mutex
private

◆ stop

bool ThreadPool::stop
private

◆ tasks

std::queue< std::function<void()> > ThreadPool::tasks
private

◆ workers

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

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.