Files
Misaki.HighPerformance/Misaki.HighPerformance.Test/Jobs/JobDispatchingJob.cs
Misaki 37d548085e 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.
2026-03-04 11:43:39 +09:00

35 lines
976 B
C#

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);
}
}
}