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:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user