feat(memory): add generic IMemoryAllocator and MemoryPool

Refactored Arena, DynamicArena, FreeList, and Stack to implement the new IMemoryAllocator<TSelf, TOpts> interface, standardizing allocation and free methods. Introduced MemoryPool<T, TOpts> for allocator lifetime management and AllocationHandle access. Updated Program.cs to use MemoryPool, replacing AllocationManager. Minor project file updates included.
This commit is contained in:
2026-03-18 21:19:51 +09:00
parent 641b459997
commit faf87953a3
8 changed files with 150 additions and 21 deletions

View File

@@ -109,3 +109,12 @@ public interface IAllocator
get;
}
}
public unsafe interface IMemoryAllocator<TSelf, TOpts> : IDisposable
where TSelf : unmanaged, IMemoryAllocator<TSelf, TOpts>
{
static abstract TSelf Create(in TOpts opts);
void* Allocate(nuint size, nuint alignment, AllocationOption option = AllocationOption.None);
void Free(void* ptr);
}