using System.Runtime.CompilerServices;
namespace Misaki.HighPerformance.LowLevel.Buffer;
[Flags]
public enum AllocationOption : byte
{
///
/// Default allocation option. Values are uninitialized.
///
None = 0,
///
/// Clear the memory to zero upon allocation.
///
Clear = 1 << 0
}
internal static class AllocationOptionExtensions
{
// HasFlag still cuase boxing in debug mode, so we implement our own version of HasFlag to avoid boxing.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool HasOption(this AllocationOption options, AllocationOption flag)
{
return (options & flag) != 0;
}
}
[Obsolete("Use AllocationHandle instead.")]
public enum Allocator : byte
{
// Make the first allocator as invalid because we don't want to user create a default collection without passing any parameters
///
/// The invalid allocator. This value is reserved and should not be used for actual memory allocations. It can be used to indicate an uninitialized or invalid state in allocation scenarios.
///
Invalid,
///
/// Allocator for temporary allocations. Allocations are automatically released after use automatically.
///
Temp,
///
/// Allocator for persistent allocations using a free list. Allocations are not automatically released after use, but can be reused to reduce fragmentation, system call and improve performance.
///
FreeList,
///
/// Allocator for persistent allocations. Allocations are not automatically released after use.
///
Persistent,
}