Added: - Added `JobExecutor.cs` for job execution management. - Added `JobInfo.cs` to hold job execution information. - Added `TestJobSystem.cs` for unit tests of the job system. - Added `TestJobs.cs` for additional job implementation tests. - Added `WorkerThread.cs` to manage worker threads for jobs. Changed: - Changed `AssemblyInfo.cs.cs` to include a global using directive for `unsafe JobExecuteFunc`. - Changed `IJob.cs` to include an overload of the `Execute` method with a `threadIndex` parameter. - Changed `JobHandle.cs` to include an `IsValid` property and updated internal structure. - Changed `JobScheduler.cs` to improve job scheduling and management. - Changed `JobsUtility.cs` to enhance job management functions. - Changed `MemoryBlock.cs` to reference the heap from which memory was allocated. - Changed `ParallelNoiseBenchmark.cs` to include benchmarks for the job system. - Changed `Program.cs` to execute benchmarks instead of previous test code. Removed: - Removed `.gitignore` entries for default ignored files. - Removed `JobBase.cs` to shift from structs to classes for jobs. - Removed `JobExtensions.cs` indicating a change in job scheduling. - Removed `JobStruct.cs` indicating a change in job structure. - Removed `encodings.xml`, `indexLayout.xml`, and `vcs.xml` files to simplify project configuration. - Removed fields from `JobData.cs` to simplify the job data structure. - Removed `TestJobSystem.csproj` entries related to old project structure.
45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
namespace Misaki.HighPerformance.Jobs;
|
|
|
|
public enum JobStatus
|
|
{
|
|
Invalid = -1,
|
|
Created = 0,
|
|
Scheduled = 1,
|
|
Running = 2,
|
|
Completed = 3
|
|
}
|
|
|
|
internal unsafe struct JobInfo
|
|
{
|
|
public const int MAX_DEPENDENTS = 8;
|
|
|
|
// The list of jobs that are waiting for THIS job to complete.
|
|
public fixed int dependentsID[MAX_DEPENDENTS]; // The actual list of IDs
|
|
public fixed int dependentsGeneration[MAX_DEPENDENTS]; // The actual list of generations
|
|
public int dependentCount;
|
|
|
|
public JobRanges jobRanges;
|
|
|
|
public void* pJobData;
|
|
public JobExecuteFunc executeDelegate;
|
|
|
|
public JobStatus status;
|
|
public int remainingBatches;
|
|
|
|
public int threadIndex; // The preferred thread index to run this job on, -1 means any thread
|
|
public int dependencyCount; // Numbers of jobs that this job depends on, when it reaches 0, the job can be executed
|
|
}
|
|
|
|
internal struct JobRanges
|
|
{
|
|
public int batchSize;
|
|
public int totalIteration;
|
|
public int currentIndex;
|
|
|
|
public static JobRanges Single => new()
|
|
{
|
|
batchSize = 1,
|
|
totalIteration = 1,
|
|
currentIndex = 0,
|
|
};
|
|
} |