PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
PixelBullet::ThreadPool Class Reference

A fixed-size pool of threads. More...

#include <ThreadPool.hpp>

Public Member Functions

 ThreadPool (uint32_t threadCount=std::thread::hardware_concurrency())
 Constructs the pool with the given number of threads. Defaults to the hardware concurrency.
 
 ~ThreadPool ()
 Waits for all tasks to complete and then stops the pool.
 
template<typename F , typename... Args>
auto Enqueue (F &&f, Args &&... args)
 Enqueues a task to be executed by the thread pool.
 
void Wait ()
 Waits until the task queue is empty.
 
const std::vector< std::thread > & GetWorkers () const
 Returns the worker threads.
 

Detailed Description

A fixed-size pool of threads.

Constructor & Destructor Documentation

◆ ThreadPool()

PixelBullet::ThreadPool::ThreadPool ( uint32_t threadCount = std::thread::hardware_concurrency())
explicit

Constructs the pool with the given number of threads. Defaults to the hardware concurrency.

◆ ~ThreadPool()

PixelBullet::ThreadPool::~ThreadPool ( )

Waits for all tasks to complete and then stops the pool.

Member Function Documentation

◆ Enqueue()

template<typename F , typename... Args>
auto PixelBullet::ThreadPool::Enqueue ( F && f,
Args &&... args )

Enqueues a task to be executed by the thread pool.

◆ GetWorkers()

const std::vector< std::thread > & PixelBullet::ThreadPool::GetWorkers ( ) const
inline

Returns the worker threads.

◆ Wait()

void PixelBullet::ThreadPool::Wait ( )

Waits until the task queue is empty.


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