Raven Engine v0.1
Loading...
Searching...
No Matches
Raven::ThreadPool Class Reference

A thread pool for scheduling and executing jobs in parallel. More...

#include <ThreadPool.h>

Public Member Functions

 ThreadPool (u8 threadCount)
 Constructs the thread pool with a given number of threads.
 ~ThreadPool ()
 Destructor that stops all threads and cleans up.
void Enqueue (Job job)
 Adds a job to the pool's queue to be executed by a worker.

Detailed Description

A thread pool for scheduling and executing jobs in parallel.

Creates a fixed number of worker threads that wait on a condition variable for new jobs to arrive in the JobQueue. Jobs are enqueued via Enqueue(), and workers automatically pick them up and execute them.

Constructor & Destructor Documentation

◆ ThreadPool()

Raven::ThreadPool::ThreadPool ( u8 threadCount)
inlineexplicit

Constructs the thread pool with a given number of threads.

Parameters
threadCountThe number of worker threads to spawn. If zero, defaults to 25% of the hardware concurrency.

◆ ~ThreadPool()

Raven::ThreadPool::~ThreadPool ( )
inline

Destructor that stops all threads and cleans up.

Gracefully stops the thread pool and joins all worker threads.

Member Function Documentation

◆ Enqueue()

void Raven::ThreadPool::Enqueue ( Job job)
inline

Adds a job to the pool's queue to be executed by a worker.

Parameters
jobThe job to enqueue for execution.

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