Raftel Engine
 
Loading...
Searching...
No Matches
job_system.hpp File Reference

JobSystem class for managing multi-threaded task execution. More...

#include <optional>
#include <vector>
#include <thread>
#include <mutex>
#include <functional>
#include <queue>
#include <future>
#include <memory>
#include <raftel/global_macros.hpp>

Go to the source code of this file.

Classes

class  Raftel::JobSystem
 A multi-threaded job system for parallel task execution. More...
 

Detailed Description

JobSystem class for managing multi-threaded task execution.

Date
2025-03-10
Author
Carlos Mazcuñán Blanes
Marc Folgado Balbás

The JobSystem class provides a simple way to manage multi-threaded jobs. It creates a thread pool equal to the number of CPU cores available and allows users to enqueue tasks that will be executed asynchronously by worker threads.

Usage Example:

auto jobSystem = Raftel::JobSystem::make();
// Submit a task and get a future result
auto futureResult = jobSystem->AddWork([](int a, int b) {
return a + b;
}, 5, 3);
// Wait for the result
int result = futureResult.get(); // result = 8
static std::unique_ptr< JobSystem > make()
Factory method to create a JobSystem instance.

Definition in file job_system.hpp.