#include <Scheduler.hpp>
A Scheduler takes pre-allocated jobs and schedules them onto worker threads owned by the internal scheduler
Public Member Functions | |
| Scheduler ()=default | |
| ~Scheduler () | |
| Calls shutdown before destruction. More... | |
| uint32_t | auto_worker_count_value () |
Gets the number of threads created when auto_worker_count is used on startup. More... | |
| void | startup (int32_t num_threads, int32_t num_main_threads) |
| void | shutdown () |
| void | schedule_job (Job *job) |
| void | register_main_thread () |
| Worker * | thread_local_worker () |
| Gets a pointer to the current threads associated worker. More... | |
| uint32_t | core_count () |
| Gets the number of real CPU cores on the current platform. More... | |
| uint32_t | hardware_thread_count () |
| Gets the number of threads available on the current platform including hyperthreads. More... | |
| uint32_t | num_workers () |
| Gets the number of workers active within the scheduler. More... | |
| uint32_t | num_main_threads () |
| Gets the max number of main threads the scheduler can support. More... | |
Static Public Attributes | |
| static constexpr int32_t | auto_thread_count = -1 |
| Flag for letting the scheduler decide how many worker threads to create. More... | |
| static constexpr uint32_t | job_capacity_per_worker = 4096 |
|
default |
| jobrocket::Scheduler::~Scheduler | ( | ) |
Calls shutdown before destruction.
| uint32_t jobrocket::Scheduler::auto_worker_count_value | ( | ) |
Gets the number of threads created when auto_worker_count is used on startup.
|
inline |
Gets the number of real CPU cores on the current platform.
|
inline |
Gets the number of threads available on the current platform including hyperthreads.
|
inline |
Gets the max number of main threads the scheduler can support.
|
inline |
Gets the number of workers active within the scheduler.
| void jobrocket::Scheduler::register_main_thread | ( | ) |
Registers the current thread as a main thread as long as the amount of main threads registered doesn't exceed num_main_threads. Can be called from any std::thread and is used to register threads that interact with the Scheduler and job system but aren't worker threads - A games render thread for example.
| void jobrocket::Scheduler::schedule_job | ( | Job * | job | ) |
Schedules a job onto the current threads local worker queue, making the job ready to execute
| void jobrocket::Scheduler::shutdown | ( | ) |
Shuts down the scheduler by waiting until all workers have completed the current job. All jobs sitting in worker queues are discarded
| void jobrocket::Scheduler::startup | ( | int32_t | num_threads, |
| int32_t | num_main_threads | ||
| ) |
Starts the scheduler and all worker threads. Makes the startup thread wait until all workers are ready
| Worker * jobrocket::Scheduler::thread_local_worker | ( | ) |
Gets a pointer to the current threads associated worker.
|
static |
Flag for letting the scheduler decide how many worker threads to create.
|
static |