Added new TempJobAllocator

Added new AllocationHandle property in Stack.Scope.

Changed the ref AllocationHandle constructor parameter to AllocationHandle on of all UnsafeCollection types
Removed Allocator.Stack. Use Stack.Scope.AllocationHandle to allocate on stack instead.
This commit is contained in:
2025-12-06 22:16:39 +09:00
parent d6c472753d
commit f3b0f295a8
24 changed files with 301 additions and 170 deletions

View File

@@ -14,11 +14,15 @@ public unsafe struct Stack : IDisposable
public readonly ref struct Scope : IDisposable
{
private readonly Stack* _allocator;
private readonly AllocationHandle _handle;
private readonly nuint _originalOffset;
internal Scope(Stack* allocator)
public readonly AllocationHandle AllocationHandle => _handle;
internal Scope(Stack* allocator, AllocationHandle handle)
{
_allocator = allocator;
_handle = handle;
_originalOffset = allocator->_offset;
_allocator->_activeScopeCount++;
}
@@ -84,12 +88,15 @@ public unsafe struct Stack : IDisposable
/// <summary>
/// Creates a new scope instance associated with the current stack context.
/// </summary>
/// <remarks>
/// The instance of <see cref="Stack"/> must be pinned or allocated on the native heap to ensure that the pointer remains valid for the lifetime of the scope.
/// </remarks>
/// <returns>A <see cref="Scope"/> object that represents a scope tied to this stack.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Scope CreateScope()
public Scope CreateScope(AllocationHandle handle)
{
EnsureInitialize();
return new Scope((Stack*)Unsafe.AsPointer(ref this));
return new Scope((Stack*)Unsafe.AsPointer(ref this), handle);
}
/// <summary>
@@ -152,4 +159,4 @@ public unsafe struct Stack : IDisposable
_size = 0;
_offset = 0;
}
}
}