Refactor to use MHP_ENABLE_SAFETY_CHECKS, MHP_ENABLE_STACKTRACE, and MHP_ENABLE_MIMALLOC for feature toggling. Remove FreeList allocator in JobSchedular and debug-layer code, simplifying memory management. Improve memory leak detection and reporting, update memory allocation API, and guard all safety/debug features with new defines. Update csproj files, README, and code samples to match new API and toggles. Fix and improve collection types for correct behavior with and without safety checks. The codebase is now more modular and easier to configure for different build environments. BREAKING CHANGE: Old defines (ENABLE_SAFETY_CHECKS, ENABLE_DEBUG_LAYER, ENABLE_MIMALLOC) are replaced with MHP_* equivalents. FreeList allocator and related debug features are removed. Some APIs and behaviors have changed for safety/debug configuration.
77 lines
1.5 KiB
Markdown
77 lines
1.5 KiB
Markdown
# Misaki.HighPerformance.Jobs
|
|
|
|
A zero-allocation-oriented job system for C#.
|
|
|
|
This package provides job contracts, scheduling, worker threads, dependency handling, and temporary allocation support for high-throughput work execution.
|
|
|
|
## What it includes
|
|
|
|
- single-job execution
|
|
- parallel-for job execution
|
|
- parallel range jobs
|
|
- job handles and dependency tracking
|
|
- worker thread management
|
|
- temporary job allocation support
|
|
|
|
## Highlights
|
|
|
|
- designed to minimize allocations during scheduling and execution
|
|
- supports dependency composition and wait operations
|
|
- suitable for frame-based engines, simulations, batch processing, and custom runtimes
|
|
- integrates with the low-level allocation layer
|
|
|
|
## Main types
|
|
|
|
- `IJob`
|
|
- `IJobParallelFor`
|
|
- `IJobParallel`
|
|
- `JobScheduler`
|
|
- `JobHandle`
|
|
- `JobExecutionContext`
|
|
- `JobState`
|
|
- `WorkerThread`
|
|
- `TempJobAllocator`
|
|
|
|
## Example
|
|
|
|
```csharp
|
|
using Misaki.HighPerformance.Jobs;
|
|
|
|
public struct AddJob : IJob
|
|
{
|
|
public int* pA;
|
|
public int* pB;
|
|
public int* pResult;
|
|
|
|
public void Execute(ref readonly JobExecutionContext ctx)
|
|
{
|
|
*pResult = *pA + *pB;
|
|
}
|
|
}
|
|
|
|
int a = 5;
|
|
int b = 10;
|
|
int result = 0;
|
|
|
|
var job = new AddJob
|
|
{
|
|
pA = &a,
|
|
pB = &b,
|
|
pResult = &result
|
|
};
|
|
|
|
JobHandle handle = jobScheduler.Schedule(job);
|
|
jobScheduler.Wait(handle);
|
|
|
|
```
|
|
|
|
## Package reference
|
|
|
|
```bash
|
|
dotnet add package Misaki.HighPerformance.Jobs
|
|
```
|
|
|
|
## Notes
|
|
|
|
This project targets `net10.0`, enables unsafe code, and is packaged as content files for downstream consumption.
|