Major refactor of job system and memory allocator: - Replaced threadIndex with preferLocal for scheduling - Switched local queues to SPMCQueue for better performance - Introduced lock-free JobEdge pool for dependencies - Removed remainingBatches; use ref counting for completion - Updated all scheduling APIs and tests to new model - Optimized FreeList struct sizes and block management - Added allocation benchmarks - Disabled OwnershipTransferAnalyzer temporarily - Bumped assembly versions
35 lines
977 B
C#
35 lines
977 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, true);
|
|
handles.AddNoResize(handle);
|
|
}
|
|
}
|
|
} |