![]() |
Gaia-ECS v0.9.3
A simple and powerful entity component system
|
Public Member Functions | |
| void | make_main_thread () |
| Make the calling thread the effective main thread from the thread pool perspective. | |
| GAIA_NODISCARD uint32_t | workers () const |
| Returns the number of frame worker threads. | |
| GAIA_NODISCARD uint32_t | background_workers () const |
| Returns the number of background worker threads. | |
| void | set_max_workers (uint32_t count, uint32_t countHighPrio) |
| Set the maximum number of frame execution contexts for this system. | |
| void | set_workers_high_prio_inter (uint32_t &workerIdx, uint32_t count) |
| Updates the number of worker threads participating at high priority workloads. | |
| void | set_workers_low_prio_inter (uint32_t &workerIdx, uint32_t count) |
| Updates the number of worker threads participating at low priority workloads. | |
| void | set_workers_high_prio (uint32_t count) |
| Updates the number of worker threads participating at high priority workloads. | |
| void | set_workers_low_prio (uint32_t count) |
| Updates the number of worker threads participating at low priority workloads. | |
| void | set_background_workers (uint32_t count) |
| Updates the number of worker threads dedicated to background jobs. Background workers run jobs submitted through sched_background() and are not used by update(). They share the MaxWorkers limit with frame workers. | |
| void | dep (JobHandle jobFirst, JobHandle jobSecond) |
| Makes jobSecond depend on jobFirst. This means jobSecond will not run until jobFirst finishes. | |
| void | dep (std::span< JobHandle > jobsFirst, JobHandle jobSecond) |
| Makes jobSecond depend on the jobs listed in jobsFirst. This means jobSecond will not run until all jobs from jobsFirst finish. | |
| void | dep_refresh (JobHandle jobFirst, JobHandle jobSecond) |
| Makes jobSecond depend on jobFirst. This means jobSecond will not run until jobFirst finishes. | |
| void | dep_refresh (std::span< JobHandle > jobsFirst, JobHandle jobSecond) |
| Makes jobSecond depend on the jobs listed in jobsFirst. This means jobSecond will not run until all jobs from jobsFirst finish. | |
| template<typename TJob > | |
| JobHandle | add (TJob job) |
| Creates a threadpool job from job. | |
| void | del (JobHandle jobHandle) |
| Deletes a job handle jobHandle from the threadpool. | |
| void | submit (std::span< JobHandle > jobHandles) |
| Pushes jobHandles into the internal queue so worker threads can pick them up and execute them. If there are more jobs than the queue can handle it puts the calling thread to sleep until workers consume enough jobs. | |
| void | submit (JobHandle jobHandle) |
| Pushes jobHandle into the internal queue so worker threads can pick it up and execute it. If there are more jobs than the queue can handle it puts the calling thread to sleep until workers consume enough jobs. | |
| void | reset_state (std::span< JobHandle > jobHandles) |
| void | reset_state (JobHandle jobHandle) |
| void | reset (std::span< JobHandle > jobHandles) |
| Waits for jobHandles to finish and resets them to a reusable state. | |
| void | reset (JobHandle jobHandle) |
| Waits for jobHandle to finish and resets it to a reusable state. | |
| JobHandle | sched (Job job) |
| Schedules a job to run on a worker thread. | |
| JobHandle | sched_background (Job job) |
| Schedules a job to run on background workers. Background jobs are not drained by update() and may span multiple frames. If no background workers are configured, wait() is the explicit fallback path that can execute queued background work on the calling thread. | |
| JobHandle | sched (Job job, JobHandle dependsOn) |
| Schedules a job to run on a worker thread. | |
| JobHandle | sched_par (JobParallel job, uint32_t itemsToProcess, uint32_t groupSize) |
| Schedules a job to run on worker threads in parallel. | |
| JobHandle | sched_par (JobParallelRef job, uint32_t itemsToProcess, uint32_t groupSize) |
| Schedules a non-owning parallel job descriptor on worker threads. | |
| void | wait (JobHandle jobHandle) |
| Wait until a job associated with the jobHandle finishes executing. Cleans up any job allocations and dependencies associated with jobHandle. The calling thread participates in frame job processing until jobHandle is done. For background jobs, the calling thread only runs background work when no background workers are configured. | |
| void | update () |
| Uses the main thread to help with frame job processing. Background jobs are intentionally excluded from update(). | |
Static Public Member Functions | |
| static ThreadPool & | get () |
| static GAIA_NODISCARD uint32_t | hw_thread_cnt () |
| Returns the number of HW threads available on the system. 1 is minimum. | |
| static GAIA_NODISCARD uint32_t | hw_efficiency_cores_cnt () |
| Returns the number of efficiency cores of the system. | |
Friends | |
| class | JobManager |
|
inline |
Creates a threadpool job from job.
|
inline |
Deletes a job handle jobHandle from the threadpool.
Makes jobSecond depend on jobFirst. This means jobSecond will not run until jobFirst finishes.
| jobFirst | The job that must complete first. |
| jobSecond | The job that will run after jobFirst. |
Makes jobSecond depend on the jobs listed in jobsFirst. This means jobSecond will not run until all jobs from jobsFirst finish.
| jobsFirst | Jobs that must complete first. |
| jobSecond | The job that will run after jobsFirst. |
Makes jobSecond depend on jobFirst. This means jobSecond will not run until jobFirst finishes.
| jobFirst | The job that must complete first. |
| jobSecond | The job that will run after jobFirst. |
|
inline |
Makes jobSecond depend on the jobs listed in jobsFirst. This means jobSecond will not run until all jobs from jobsFirst finish.
| jobsFirst | Jobs that must complete first. |
| jobSecond | The job that will run after jobsFirst. |
|
inlinestatic |
Returns the number of efficiency cores of the system.
|
inlinestatic |
Returns the number of HW threads available on the system. 1 is minimum.
Waits for jobHandles to finish and resets them to a reusable state.
Schedules a job to run on background workers. Background jobs are not drained by update() and may span multiple frames. If no background workers are configured, wait() is the explicit fallback path that can execute queued background work on the calling thread.
| job | Job descriptor. |
|
inline |
Schedules a job to run on worker threads in parallel.
| job | Job descriptor |
| itemsToProcess | Total number of work items |
| groupSize | Group size per created job. If zero the threadpool decides the group size. |
|
inline |
Schedules a non-owning parallel job descriptor on worker threads.
| job | Non-owning job descriptor. |
| itemsToProcess | Total number of work items. |
| groupSize | Group size per created job. If zero the threadpool decides the group size. |
|
inline |
Updates the number of worker threads dedicated to background jobs. Background workers run jobs submitted through sched_background() and are not used by update(). They share the MaxWorkers limit with frame workers.
| count | Requested number of background worker threads. |
|
inline |
Set the maximum number of frame execution contexts for this system.
| count | Requested frame execution contexts, including the main thread. The number of spawned frame worker threads is one less. |
| countHighPrio | Number of high-priority frame execution contexts. Values larger than count are clamped. |
|
inline |
Updates the number of worker threads participating at high priority workloads.
|
inline |
Updates the number of worker threads participating at high priority workloads.
| [out] | workerIdx | Number of high priority workers. |
| count | Requested number of high priority workers. |
|
inline |
Updates the number of worker threads participating at low priority workloads.
|
inline |
Updates the number of worker threads participating at low priority workloads.
| [out] | workerIdx | Number of low priority workers. |
| count | Requested number of low priority workers. |
|
inline |
Pushes jobHandle into the internal queue so worker threads can pick it up and execute it. If there are more jobs than the queue can handle it puts the calling thread to sleep until workers consume enough jobs.
Pushes jobHandles into the internal queue so worker threads can pick them up and execute them. If there are more jobs than the queue can handle it puts the calling thread to sleep until workers consume enough jobs.
|
inline |
Wait until a job associated with the jobHandle finishes executing. Cleans up any job allocations and dependencies associated with jobHandle. The calling thread participates in frame job processing until jobHandle is done. For background jobs, the calling thread only runs background work when no background workers are configured.
| jobHandle | Job handle to wait for |