Jolt Physics
A multi core friendly Game Physics Engine
|
#include <JobSystemThreadPool.h>
Protected Member Functions | |
virtual void | QueueJob (Job *inJob) override |
Adds a job to the job queue. | |
virtual void | QueueJobs (Job **inJobs, uint inNumJobs) override |
Adds a number of jobs at once to the job queue. | |
virtual void | FreeJob (Job *inJob) override |
Frees a job. | |
Additional Inherited Members | |
Public Types inherited from JobSystem | |
using | JobFunction = function<void()> |
Main function of the job. | |
Implementation of a JobSystem using a thread pool
Note that this is considered an example implementation. It is expected that when you integrate the physics engine into your own project that you'll provide your own implementation of the JobSystem built on top of whatever job system your project uses.
JobSystemThreadPool::JobSystemThreadPool | ( | uint | inMaxJobs, |
uint | inMaxBarriers, | ||
int | inNumThreads = -1 ) |
Creates a thread pool.
|
default |
|
overridevirtual |
|
overridevirtual |
Create a new job, the job is started immediately if inNumDependencies == 0 otherwise it starts when RemoveDependency causes the dependency counter to reach 0.
Implements JobSystem.
Frees a job.
Implements JobSystem.
Get maximum number of concurrently executing jobs.
Implements JobSystem.
JPH_NAMESPACE_BEGIN void JobSystemThreadPool::Init | ( | uint | inMaxJobs, |
uint | inMaxBarriers, | ||
int | inNumThreads = -1 ) |
Initialize the thread pool
inMaxJobs | Max number of jobs that can be allocated at any time |
inMaxBarriers | Max number of barriers that can be allocated at any time |
inNumThreads | Number of threads to start (the number of concurrent jobs is 1 more because the main thread will also run jobs while waiting for a barrier to complete). Use -1 to auto detect the amount of CPU's. |
Adds a job to the job queue.
Implements JobSystem.
Adds a number of jobs at once to the job queue.
Implements JobSystem.
Change the max concurrency after initialization.