10 JPH_ASSERT(old_value > 0 && old_value !=
cExecutingState && old_value !=
cDoneState,
"Job is queued, running or done, it is not allowed to add a dependency to a running job");
15 uint32 old_value = mNumDependencies.fetch_sub(inCount, memory_order_release);
16 JPH_ASSERT(old_value != cExecutingState && old_value != cDoneState,
"Job is running or done, it is not allowed to add a dependency to a running job");
17 uint32 new_value = old_value - inCount;
18 JPH_ASSERT(old_value > new_value,
"Test wrap around, this is a logic error");
19 return new_value == 0;
24 if (RemoveDependency(inCount))
25 mJobSystem->QueueJob(
this);
35 JobSystem *job_system = inHandles->GetPtr()->GetJobSystem();
39 Job **next_job = jobs_to_queue;
42 for (
const JobHandle *handle = inHandles, *handle_end = inHandles + inNumHandles; handle < handle_end; ++handle)
44 Job *job = handle->GetPtr();
51 uint num_jobs_to_queue =
uint(next_job - jobs_to_queue);
52 if (num_jobs_to_queue != 0)
53 job_system->
QueueJobs(jobs_to_queue, num_jobs_to_queue);
#define JPH_STACK_ALLOC(n)
Definition Core.h:506
unsigned int uint
Definition Core.h:453
#define JPH_NAMESPACE_END
Definition Core.h:379
std::uint32_t uint32
Definition Core.h:456
#define JPH_NAMESPACE_BEGIN
Definition Core.h:373
#define JPH_IF_ENABLE_ASSERTS(...)
Definition IssueReporting.h:35
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
#define JPH_PROFILE_FUNCTION()
Scope profiling for function.
Definition Profiler.h:271
Definition JobSystem.h:80
static void sRemoveDependencies(const JobHandle *inHandles, uint inNumHandles, int inCount=1)
Remove a dependency from a batch of jobs at once, this can be more efficient than removing them one b...
Definition JobSystem.inl:28
A class that contains information for a single unit of work.
Definition JobSystem.h:171
bool RemoveDependency(int inCount)
Definition JobSystem.inl:13
void AddDependency(int inCount)
Add to the dependency counter.
Definition JobSystem.inl:7
static constexpr uint32 cDoneState
Value of mNumDependencies when job is done executing.
Definition JobSystem.h:281
JobSystem * GetJobSystem()
Get the jobs system to which this job belongs.
Definition JobSystem.h:188
static constexpr uint32 cExecutingState
Value of mNumDependencies when job is executing.
Definition JobSystem.h:280
void RemoveDependencyAndQueue(int inCount)
Definition JobSystem.inl:22
Definition JobSystem.h:70
virtual void QueueJobs(Job **inJobs, uint inNumJobs)=0
Adds a number of jobs at once to the job queue.