Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
JobSystemSingleThreaded Class Referencefinal

Implementation of a JobSystem without threads, runs jobs as soon as they are added. More...

#include <JobSystemSingleThreaded.h>

Inheritance diagram for JobSystemSingleThreaded:
JobSystem NonCopyable

Classes

class  BarrierImpl
 

Public Member Functions

JPH_OVERRIDE_NEW_DELETE JobSystemSingleThreaded ()=default
 Constructor.
 
 JobSystemSingleThreaded (uint inMaxJobs)
 
void Init (uint inMaxJobs)
 
virtual int GetMaxConcurrency () const override
 Get maximum number of concurrently executing jobs.
 
virtual JobHandle CreateJob (const char *inName, ColorArg inColor, const JobFunction &inJobFunction, uint32 inNumDependencies=0) override
 
virtual BarrierCreateBarrier () override
 Create a new barrier, used to wait on jobs.
 
virtual void DestroyBarrier (Barrier *inBarrier) override
 Destroy a barrier when it is no longer used. The barrier should be empty at this point.
 
virtual void WaitForJobs (Barrier *inBarrier) override
 Wait for a set of jobs to be finished, note that only 1 thread can be waiting on a barrier at a time.
 
- Public Member Functions inherited from JobSystem
virtual ~JobSystem ()=default
 Destructor.
 
- Public Member Functions inherited from NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
void operator= (const NonCopyable &)=delete
 

Protected Types

using AvailableJobs = FixedSizeFreeList< Job >
 Array of jobs (fixed size)
 

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.
 

Protected Attributes

BarrierImpl mDummyBarrier
 Shared barrier since the barrier implementation does nothing.
 
AvailableJobs mJobs
 

Additional Inherited Members

- Public Types inherited from JobSystem
using JobFunction = function< void()>
 Main function of the job.
 

Detailed Description

Implementation of a JobSystem without threads, runs jobs as soon as they are added.

Member Typedef Documentation

◆ AvailableJobs

Array of jobs (fixed size)

Constructor & Destructor Documentation

◆ JobSystemSingleThreaded() [1/2]

JPH_OVERRIDE_NEW_DELETE JobSystemSingleThreaded::JobSystemSingleThreaded ( )
default

Constructor.

◆ JobSystemSingleThreaded() [2/2]

JobSystemSingleThreaded::JobSystemSingleThreaded ( uint  inMaxJobs)
inlineexplicit

Member Function Documentation

◆ CreateBarrier()

JobSystem::Barrier * JobSystemSingleThreaded::CreateBarrier ( )
overridevirtual

Create a new barrier, used to wait on jobs.

Implements JobSystem.

◆ CreateJob()

JobHandle JobSystemSingleThreaded::CreateJob ( const char *  inName,
ColorArg  inColor,
const JobFunction inJobFunction,
uint32  inNumDependencies = 0 
)
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.

◆ DestroyBarrier()

void JobSystemSingleThreaded::DestroyBarrier ( Barrier inBarrier)
overridevirtual

Destroy a barrier when it is no longer used. The barrier should be empty at this point.

Implements JobSystem.

◆ FreeJob()

void JobSystemSingleThreaded::FreeJob ( Job inJob)
overrideprotectedvirtual

Frees a job.

Implements JobSystem.

◆ GetMaxConcurrency()

virtual int JobSystemSingleThreaded::GetMaxConcurrency ( ) const
inlineoverridevirtual

Get maximum number of concurrently executing jobs.

Implements JobSystem.

◆ Init()

JPH_NAMESPACE_BEGIN void JobSystemSingleThreaded::Init ( uint  inMaxJobs)

Initialize the job system

Parameters
inMaxJobsMax number of jobs that can be allocated at any time

◆ QueueJob()

void JobSystemSingleThreaded::QueueJob ( Job inJob)
overrideprotectedvirtual

Adds a job to the job queue.

Implements JobSystem.

◆ QueueJobs()

void JobSystemSingleThreaded::QueueJobs ( Job **  inJobs,
uint  inNumJobs 
)
overrideprotectedvirtual

Adds a number of jobs at once to the job queue.

Implements JobSystem.

◆ WaitForJobs()

void JobSystemSingleThreaded::WaitForJobs ( Barrier inBarrier)
overridevirtual

Wait for a set of jobs to be finished, note that only 1 thread can be waiting on a barrier at a time.

Implements JobSystem.

Member Data Documentation

◆ mDummyBarrier

BarrierImpl JobSystemSingleThreaded::mDummyBarrier
protected

Shared barrier since the barrier implementation does nothing.

◆ mJobs

AvailableJobs JobSystemSingleThreaded::mJobs
protected

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