Refactor job API: add JobExecutionContext, update tests
Major breaking change: job interfaces now use JobExecutionContext instead of threadIndex, enabling thread-aware and dynamic job dispatching. Updated all job system, SPMD, and test code to match. Collections improved with new methods and clearer enumerators. Renamed IJobScheduler.WaitComplete to Wait. Incremented project versions. Includes bug fixes, documentation, and style updates.
This commit is contained in:
35
Misaki.HighPerformance.Test/Jobs/JobDispatchingJob.cs
Normal file
35
Misaki.HighPerformance.Test/Jobs/JobDispatchingJob.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Misaki.HighPerformance.Jobs;
|
||||
using Misaki.HighPerformance.LowLevel.Collections;
|
||||
|
||||
namespace Misaki.HighPerformance.Test.Jobs;
|
||||
|
||||
internal struct JobDispatchingJob : IJobParallelFor
|
||||
{
|
||||
public UnsafeArray<UnsafeArray<int>> data;
|
||||
public UnsafeList<JobHandle>.ParallelWriter handles;
|
||||
|
||||
private struct InnerJob : IJobParallelFor
|
||||
{
|
||||
public UnsafeArray<int> data;
|
||||
|
||||
public void Execute(int loopIndex, ref readonly JobExecutionContext ctx)
|
||||
{
|
||||
ref var value = ref data[loopIndex];
|
||||
value *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(int loopIndex, ref readonly JobExecutionContext ctx)
|
||||
{
|
||||
if (loopIndex % 2 == 0)
|
||||
{
|
||||
var innerJob = new InnerJob
|
||||
{
|
||||
data = data[loopIndex]
|
||||
};
|
||||
|
||||
var handle = ctx.JobScheduler.ScheduleParallelFor(in innerJob, data[loopIndex].Length, 64, ctx.ThreadIndex);
|
||||
handles.AddNoResize(handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user