VEX Engine
Retro looking game engine made in vulkan mostly because i wanted to understand it better.
Loading...
Searching...
No Matches
vex::ThreadPool Class Reference

Public Member Functions

 ThreadPool (size_t threads=std::thread::hardware_concurrency())
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 condition
bool stop

Detailed Description

Definition at line 11 of file ThreadPool.hpp.

Constructor & Destructor Documentation

◆ ThreadPool()

vex::ThreadPool::ThreadPool ( size_t threads = std::thread::hardware_concurrency())
inline

Definition at line 13 of file ThreadPool.hpp.

◆ ~ThreadPool()

vex::ThreadPool::~ThreadPool ( )
inline

Definition at line 44 of file ThreadPool.hpp.

Member Function Documentation

◆ enqueue()

template<class F, class... Args>
auto vex::ThreadPool::enqueue ( F && f,
Args &&... args ) -> std::future< std::invoke_result_t< F, Args... > >
inline

Definition at line 31 of file ThreadPool.hpp.

Member Data Documentation

◆ condition

std::condition_variable vex::ThreadPool::condition
private

Definition at line 56 of file ThreadPool.hpp.

◆ queue_mutex

std::mutex vex::ThreadPool::queue_mutex
private

Definition at line 55 of file ThreadPool.hpp.

◆ stop

bool vex::ThreadPool::stop
private

Definition at line 57 of file ThreadPool.hpp.

◆ tasks

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

Definition at line 54 of file ThreadPool.hpp.

◆ workers

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

Definition at line 53 of file ThreadPool.hpp.


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