18 lines
No EOL
587 B
C#
18 lines
No EOL
587 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);
|
|
|
|
public static MemoryManager<T> AllocateImmovable<T>(int count) where T : unmanaged
|
|
=> new ImmovableMemory<T>(count);
|
|
} |