15 lines
457 B
C#
15 lines
457 B
C#
|
|
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);
|
||
|
|
}
|