44 class BarrierImpl :
public Barrier
51 virtual ~BarrierImpl()
override;
54 virtual void AddJob(
const JobHandle &inJob)
override;
55 virtual void AddJobs(
const JobHandle *inHandles,
uint inNumHandles)
override;
58 inline bool IsEmpty()
const {
return mJobReadIndex == mJobWriteIndex; }
64 atomic<bool> mInUse {
false };
68 virtual void OnJobFinished(
Job *inJob)
override;
71 static constexpr uint cMaxJobs = 2048;
73 atomic<Job *> mJobs[cMaxJobs];
76 atomic<int> mNumToAcquire { 0 };
81 uint mMaxBarriers = 0;
82 BarrierImpl * mBarriers =
nullptr;
#define JPH_CACHE_LINE_SIZE
Definition Core.h:334
unsigned int uint
Definition Core.h:309
#define JPH_NAMESPACE_END
Definition Core.h:240
#define JPH_NAMESPACE_BEGIN
Definition Core.h:234
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:29
A job barrier keeps track of a number of jobs and allows waiting until they are all completed.
Definition JobSystem.h:123
friend class Job
Job needs to be able to call OnJobFinished.
Definition JobSystem.h:137
Definition JobSystem.h:80
Definition JobSystem.h:70
Definition JobSystemWithBarrier.h:24
void Init(uint inMaxBarriers)
Definition JobSystemWithBarrier.cpp:167
virtual Barrier * CreateBarrier() override
Create a new barrier, used to wait on jobs.
Definition JobSystemWithBarrier.cpp:191
virtual void DestroyBarrier(Barrier *inBarrier) override
Destroy a barrier when it is no longer used. The barrier should be empty at this point.
Definition JobSystemWithBarrier.cpp:206
virtual ~JobSystemWithBarrier() override
Definition JobSystemWithBarrier.cpp:181
JobSystemWithBarrier()=default
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.
Definition JobSystemWithBarrier.cpp:219
Definition Semaphore.h:23