Bash++
Bash++ compiler internal documentation
|
A thread pool implementation that manages a pool of worker threads to execute tasks concurrently. More...
#include <ThreadPool.h>
Public Member Functions | |
ThreadPool (size_t threads=std::thread::hardware_concurrency()) | |
~ThreadPool () | |
void | enqueue (std::function< void()> task) |
Enqueue a new task to be executed by the thread pool. | |
void | cleanup () |
size_t | getThreadCount () const |
Private Attributes | |
std::vector< std::thread > | workers |
std::queue< std::function< void()> > | tasks |
std::mutex | queue_mutex |
std::condition_variable | condition |
bool | stop |
A thread pool implementation that manages a pool of worker threads to execute tasks concurrently.
Copyright (C) 2025 Andrew S. Rightenburg Bash++: Bash with classes
By default, the pool is initialized with a number of available worker threads equal to the number of hardware threads available on the system. Tasks can be enqueued to be executed by the worker threads, which will run them concurrently.
ThreadPool::ThreadPool | ( | size_t | threads = std::thread::hardware_concurrency() | ) |
Copyright (C) 2025 Andrew S. Rightenburg Bash++: Bash with classes
ThreadPool::~ThreadPool | ( | ) |
void ThreadPool::cleanup | ( | ) |
void ThreadPool::enqueue | ( | std::function< void()> | task | ) |
Enqueue a new task to be executed by the thread pool.
task | A function pointer to be excecuted by a worker thread. |
size_t ThreadPool::getThreadCount | ( | ) | const |
|
private |
|
private |
|
private |
|
private |
|
private |