Skip to content

Commit 95ebe7b

Browse files
committed
Update World.Jobs.cs
1 parent fb7fe1f commit 95ebe7b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/Arch/Core/Jobs/World.Jobs.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,12 @@ public void InlineParallelChunkQuery<T>(in QueryDescription queryDescription, in
132132
/// <summary>
133133
/// Similar to InlineParallelChunkQuery but instead runs the <see cref="IParallelChunkJobProducer"/> on each chunk in parallel.
134134
/// This makes it possible to run parallel on chunks that are few, but contain lots of entities.
135+
/// <param name="queryDescription">The <see cref="QueryDescription"/> which specifies which <see cref="Chunk"/>'s are searched for.</param>
136+
/// <param name="innerJob">The struct instance of the generic type being invoked.</param>
137+
/// <param name="parent">The parent <see cref="JobHandle"/> to set as parent for the job.</param>
138+
/// <returns>A <see cref="JobHandle"/> that can be used to wait for this job to finish.</returns>
135139
/// </summary>
136-
public JobHandle AdvancedInlineParallelChunkQuery<T>(in QueryDescription queryDescription, in T innerJob) where T : struct, IParallelChunkJobProducer
140+
public JobHandle AdvancedInlineParallelChunkQuery<T>(in QueryDescription queryDescription, in T innerJob, JobHandle parent) where T : struct, IParallelChunkJobProducer
137141
{
138142
// Job scheduler needs to be initialized.
139143
if (SharedJobScheduler is null)
@@ -143,23 +147,22 @@ public JobHandle AdvancedInlineParallelChunkQuery<T>(in QueryDescription queryDe
143147

144148
// Cast pool in an unsafe fast way and run the query.
145149
var query = Query(in queryDescription);
146-
var parentHandle = SharedJobScheduler.Schedule();
150+
var currentParentHandle = SharedJobScheduler.Schedule(parent);
147151
foreach (var archetype in query.GetArchetypeIterator())
148152
{
149153
for (int i = 0; i < archetype.Chunks.Count; i++)
150154
{
151155
ref var chunk = ref archetype.Chunks[i];
152156
var jobCopy = innerJob;
153157
jobCopy.SetChunk(chunk);
154-
var job = new ParallelJobProducer<T>(0, chunk.Count, jobCopy, SharedJobScheduler, 1, true);
155-
job.GetHandle().SetParent(parentHandle);
158+
var job = new ParallelJobProducer<T>(0, chunk.Count, jobCopy, 1, true);
159+
job.GetHandle().SetParent(currentParentHandle);
156160
job.CheckAndSplit();
157161
SharedJobScheduler.Flush(job.GetHandle());
158162
}
159163
}
160-
161-
SharedJobScheduler.Flush(parentHandle);
162-
return parentHandle;
164+
SharedJobScheduler.Flush(currentParentHandle);
165+
return currentParentHandle;
163166
}
164167

165168
/// <summary>

0 commit comments

Comments
 (0)