C# Класс BEPUutilities2.ResourceManagement.Allocator

Represents a chunk of abstract memory supporting allocations and deallocations. Never moves any memory.
Uses an extremely simple ring buffer that makes no attempt to skip groups of allocations. Not particularly efficient.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Allocate ( ulong id, long size, long &outputStart ) : bool

Attempts to allocate a range of memory.

Allocator ( long memoryPoolSize, BufferPool idBufferPool = null, BufferPool allocationBufferPool = null, BufferPool tableBufferPool = null ) : System

Creates a new memory pool.

CanFit ( long size, QuickList ignoredIds = null ) : bool

Checks if a block of memory can fit into the current state of the allocator.

Deallocate ( ulong id ) : bool

Removes the memory associated with the id from the pool.

GetLargestContiguousSize ( long &largestContiguous, long &totalFreeSpace ) : void

Gets the size of the largest contiguous area and the total free space in the allocator. Not very efficient; runs in linear time for the number of allocations.

IncrementalCompact ( ulong &id, long &size, long &oldStart, long &newStart ) : bool

Finds the first allocation with empty space before it and pulls it forward to close the gap. Assumes the ability to perform synchronous reallocation.

Resize ( ulong id, long size, long &oldStart, long &newStart ) : bool

Attempts to resize a given allocation to a new size. If the new size is smaller, the start index remains unchanged.

TryGetAllocationRegion ( ulong allocationId, Allocation &allocation ) : bool

Gets the allocation region associated with the given allocation id if it is present.

Приватные методы

Метод Описание
AddAllocation ( ulong id, long start, long end, Allocation &allocation, Allocation &nextAllocation ) : void
Contains ( ulong id ) : bool
ValidatePointers ( ) : void

Описание методов

Allocate() публичный Метод

Attempts to allocate a range of memory.
public Allocate ( ulong id, long size, long &outputStart ) : bool
id ulong Unique id of the memory to allocate.
size long Size of the memory to allocate.
outputStart long Starting index of the allocated memory, if successful.
Результат bool

Allocator() публичный Метод

Creates a new memory pool.
public Allocator ( long memoryPoolSize, BufferPool idBufferPool = null, BufferPool allocationBufferPool = null, BufferPool tableBufferPool = null ) : System
memoryPoolSize long Size of the pool in elements.
idBufferPool BufferPool Buffer pool to use in the allocator. If null, the allocator picks.
allocationBufferPool BufferPool Buffer pool to use in the allocator. If null, the allocator picks.
tableBufferPool BufferPool Buffer pool to use in the allocator. If null, the allocator picks.
Результат System

CanFit() публичный Метод

Checks if a block of memory can fit into the current state of the allocator.
public CanFit ( long size, QuickList ignoredIds = null ) : bool
size long Size of the memory to test.
ignoredIds QuickList Ids of allocations to treat as nonexistent for the purposes of the test.
Результат bool

Deallocate() публичный Метод

Removes the memory associated with the id from the pool.
public Deallocate ( ulong id ) : bool
id ulong Id to remove.
Результат bool

GetLargestContiguousSize() публичный Метод

Gets the size of the largest contiguous area and the total free space in the allocator. Not very efficient; runs in linear time for the number of allocations.
public GetLargestContiguousSize ( long &largestContiguous, long &totalFreeSpace ) : void
largestContiguous long Largest contiguous region in the allocator. The allocator can hold an allocation up to this size.
totalFreeSpace long Total free space in the allocator.
Результат void

IncrementalCompact() публичный Метод

Finds the first allocation with empty space before it and pulls it forward to close the gap. Assumes the ability to perform synchronous reallocation.
public IncrementalCompact ( ulong &id, long &size, long &oldStart, long &newStart ) : bool
id ulong Id of the allocation to be moved, if any.
size long Size of the moved allocation.
oldStart long Old starting location of the allocation.
newStart long New starting location of the allocation.
Результат bool

Resize() публичный Метод

Attempts to resize a given allocation to a new size. If the new size is smaller, the start index remains unchanged.
public Resize ( ulong id, long size, long &oldStart, long &newStart ) : bool
id ulong Id of the allocation to resize.
size long New desired size of the allocation.
oldStart long Old start location of the allocation.
newStart long New start location of the allocation.
Результат bool

TryGetAllocationRegion() публичный Метод

Gets the allocation region associated with the given allocation id if it is present.
public TryGetAllocationRegion ( ulong allocationId, Allocation &allocation ) : bool
allocationId ulong Allocation id to look up the allocation for.
allocation Allocation Allocation associated with the id, if present.
Результат bool