diff --git a/Misaki.HighPerformance.Jobs/JobScheduler.cs b/Misaki.HighPerformance.Jobs/JobScheduler.cs index 736185e..5619bd9 100644 --- a/Misaki.HighPerformance.Jobs/JobScheduler.cs +++ b/Misaki.HighPerformance.Jobs/JobScheduler.cs @@ -6,12 +6,9 @@ using System.Runtime.CompilerServices; namespace Misaki.HighPerformance.Jobs; -/// -/// Provides a mechanism for scheduling and executing jobs across multiple worker threads. -/// -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); + } + } +} + +/// +/// Provides a mechanism for scheduling and executing jobs across multiple worker threads. +/// +public sealed unsafe partial class JobScheduler : IDisposable +{ private const int _SLEEP_THRESHOLD = 100; private FreeList _jobDataAllocator; diff --git a/Misaki.HighPerformance.Jobs/Misaki.HighPerformance.Jobs.csproj b/Misaki.HighPerformance.Jobs/Misaki.HighPerformance.Jobs.csproj index 644c91d..ec34529 100644 --- a/Misaki.HighPerformance.Jobs/Misaki.HighPerformance.Jobs.csproj +++ b/Misaki.HighPerformance.Jobs/Misaki.HighPerformance.Jobs.csproj @@ -6,7 +6,7 @@ enable enable True - 1.2.0 + 1.2.1 $(AssemblyVersion) Misaki True diff --git a/Misaki.HighPerformance.Jobs/TempJobAllocator.cs b/Misaki.HighPerformance.Jobs/TempJobAllocator.cs index 1b7c0b3..79dbf4d 100644 --- a/Misaki.HighPerformance.Jobs/TempJobAllocator.cs +++ b/Misaki.HighPerformance.Jobs/TempJobAllocator.cs @@ -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);