36 void Init(
uint inMaxBarriers);
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_EXPORT
Definition Core.h:271
#define JPH_CACHE_LINE_SIZE
Definition Core.h:521
unsigned int uint
Definition Core.h:481
#define JPH_NAMESPACE_END
Definition Core.h:414
#define JPH_NAMESPACE_BEGIN
Definition Core.h:408
constexpr bool IsPowerOf2(T inV)
Check if inV is a power of 2.
Definition Math.h:76
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:31
A job barrier keeps track of a number of jobs and allows waiting until they are all completed.
Definition JobSystem.h:123
Definition JobSystem.h:80
Definition JobSystem.h:70
virtual Barrier * CreateBarrier()=0
Create a new barrier, used to wait on jobs.
virtual void WaitForJobs(Barrier *inBarrier)=0
Wait for a set of jobs to be finished, note that only 1 thread can be waiting on a barrier at a time.
virtual void DestroyBarrier(Barrier *inBarrier)=0
Destroy a barrier when it is no longer used. The barrier should be empty at this point.
Definition JobSystemWithBarrier.h:24
JobSystemWithBarrier()=default
Definition Semaphore.h:23