Added ReleaseTempAllocator to JobScheduler

This commit is contained in:
2025-12-09 12:31:51 +09:00
parent 0438fce10e
commit a0a4b347dd
3 changed files with 19 additions and 7 deletions

View File

@@ -6,12 +6,9 @@ using System.Runtime.CompilerServices;
namespace Misaki.HighPerformance.Jobs;
/// <summary>
/// Provides a mechanism for scheduling and executing jobs across multiple worker threads.
/// </summary>
public sealed unsafe class JobScheduler : IDisposable
public unsafe partial class JobScheduler
{
private static readonly TempJobAllocator* pTempAllocator;
public static readonly TempJobAllocator* pTempAllocator;
public static AllocationHandle TempAllocatorHandle => pTempAllocator->Handle;
static JobScheduler()
@@ -20,6 +17,21 @@ public sealed unsafe class JobScheduler : IDisposable
pTempAllocator->Init();
}
public static void ReleaseTempAllocator()
{
if (pTempAllocator != null)
{
pTempAllocator->Dispose();
MemoryUtility.Free(pTempAllocator);
}
}
}
/// <summary>
/// Provides a mechanism for scheduling and executing jobs across multiple worker threads.
/// </summary>
public sealed unsafe partial class JobScheduler : IDisposable
{
private const int _SLEEP_THRESHOLD = 100;
private FreeList _jobDataAllocator;

View File

@@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>1.2.0</AssemblyVersion>
<AssemblyVersion>1.2.1</AssemblyVersion>
<Version>$(AssemblyVersion)</Version>
<Authors>Misaki</Authors>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>

View File

@@ -78,7 +78,7 @@ public unsafe struct TempJobAllocator : IAllocator, IDisposable
Interlocked.Decrement(ref selfPtr->_allocationsPerFrame[selfPtr->_currentFrameIndex]);
}
public int IncrementFrame()
public int AdvanceFrame()
{
var allocations = Interlocked.Exchange(ref _allocationsPerFrame[_currentFrameIndex], 0);