45 void Init(
uint inMaxJobs,
uint inMaxBarriers,
int inNumThreads = -1);
52 void SetNumThreads(
int inNumThreads) { StopThreads(); StartThreads(inNumThreads); }
56 virtual void QueueJob(Job *inJob)
override;
57 virtual void QueueJobs(Job **inJobs,
uint inNumJobs)
override;
58 virtual void FreeJob(Job *inJob)
override;
62 void StartThreads(
int inNumThreads);
66 void ThreadMain(
int inThreadIndex);
69 inline uint GetHead()
const;
72 inline void QueueJobInternal(Job *inJob);
75 InitExitFunction mThreadInitFunction = [](int) { };
76 InitExitFunction mThreadExitFunction = [](int) { };
86 static constexpr uint32 cQueueLength = 1024;
88 atomic<Job *> mQueue[cQueueLength];
91 atomic<uint> * mHeads =
nullptr;
98 atomic<bool> mQuit =
false;
#define JPH_EXPORT
Definition: Core.h:236
#define JPH_CACHE_LINE_SIZE
Definition: Core.h:492
#define JPH_SUPPRESS_WARNINGS_STD_BEGIN
Definition: Core.h:383
#define JPH_SUPPRESS_WARNINGS_STD_END
Definition: Core.h:395
unsigned int uint
Definition: Core.h:452
#define JPH_NAMESPACE_END
Definition: Core.h:378
std::uint32_t uint32
Definition: Core.h:455
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:372
constexpr bool IsPowerOf2(T inV)
Check if inV is a power of 2.
Definition: Math.h:73
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition: Memory.h:31
Class that holds an RGBA color with 8-bits per component.
Definition: Color.h:16
Definition: FixedSizeFreeList.h:18
Definition: JobSystem.h:80
virtual JobHandle CreateJob(const char *inName, ColorArg inColor, const JobFunction &inJobFunction, uint32 inNumDependencies=0)=0
virtual void QueueJobs(Job **inJobs, uint inNumJobs)=0
Adds a number of jobs at once to the job queue.
virtual void FreeJob(Job *inJob)=0
Frees a job.
virtual void QueueJob(Job *inJob)=0
Adds a job to the job queue.
Definition: JobSystemThreadPool.h:26
void SetThreadExitFunction(const InitExitFunction &inExitFunction)
Definition: JobSystemThreadPool.h:39
function< void(int)> InitExitFunction
Functions to call when a thread is initialized or exits, must be set before calling Init()
Definition: JobSystemThreadPool.h:37
void SetNumThreads(int inNumThreads)
Change the max concurrency after initialization.
Definition: JobSystemThreadPool.h:52
void SetThreadInitFunction(const InitExitFunction &inInitFunction)
Definition: JobSystemThreadPool.h:38
JobSystemThreadPool()=default
virtual int GetMaxConcurrency() const override
Get maximum number of concurrently executing jobs.
Definition: JobSystemThreadPool.h:48
Definition: JobSystemWithBarrier.h:24
void Init(uint inMaxBarriers)
Definition: JobSystemWithBarrier.cpp:167
Definition: Semaphore.h:23