Initial commit
This commit is contained in:
commit
ef3b7d68fb
30 changed files with 1568 additions and 0 deletions
15
Infra/Buffers/MemoryAllocator.cs
Normal file
15
Infra/Buffers/MemoryAllocator.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using System.Buffers;
|
||||
|
||||
namespace StitchATon2.Infra.Buffers;
|
||||
|
||||
public static class MemoryAllocator
|
||||
{
|
||||
public static IBuffer<T> Allocate<T>(int count) where T : unmanaged
|
||||
=> new UnmanagedMemory<T>(count);
|
||||
|
||||
public static IMemoryOwner<T> AllocateManaged<T>(int count)
|
||||
=> MemoryPool<T>.Shared.Rent(count);
|
||||
|
||||
public static ArrayOwner<T> AllocateArray<T>(int count) where T : unmanaged
|
||||
=> new(ArrayPool<T>.Shared, count);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue