Raftel Engine
 
Loading...
Searching...
No Matches
Raftel::JobSystem Class Reference

A multi-threaded job system for parallel task execution. More...

#include <job_system.hpp>

Public Member Functions

 ~JobSystem ()
 Destructor that ensures proper thread cleanup.
 
template<typename MyJobFunction, typename... Arguments>
auto AddWork (MyJobFunction &&function, Arguments &&... params) -> std::future< decltype(function(params...))>
 Deleted copy and move constructors/operators to prevent copying or moving.
 
 JobSystem ()
 Constructor that initializes worker threads.
 

Static Public Member Functions

static std::unique_ptr< JobSystemmake ()
 Factory method to create a JobSystem instance.
 

Detailed Description

A multi-threaded job system for parallel task execution.

Definition at line 51 of file job_system.hpp.

Member Function Documentation

◆ AddWork()

template<typename MyJobFunction, typename ... Arguments>
auto Raftel::JobSystem::AddWork ( MyJobFunction && function,
Arguments &&... params ) -> std::future<decltype(function(params...))>
inline

Deleted copy and move constructors/operators to prevent copying or moving.

Adds a job to the work queue.

This prevents accidental duplication or transfer of JobSystem instances, ensuring that only one instance manages the worker threads.

Adds a job to the work queue.

Template Parameters
MyJobFunctionThe type of the callable function.
ArgumentsVariadic template arguments for function parameters.
Parameters
functionThe function to be executed by a worker thread.
paramsParameters for the function.
Returns
A future object representing the result of the asynchronous job.
Template Parameters
MyJobFunctionThe type of the callable function.
ArgumentsVariadic template arguments for function parameters.
Parameters
functionThe function to be executed.
paramsParameters for the function.
Returns
A future object representing the result of the asynchronous job.

Definition at line 107 of file job_system.hpp.

◆ make()

static std::unique_ptr< JobSystem > Raftel::JobSystem::make ( )
static

Factory method to create a JobSystem instance.

Returns
A unique pointer to a new JobSystem instance.

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